#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <algorithm>

#define endl '\n'

int main() {
    std::cout.tie(0); std::iostream::sync_with_stdio(0);
    unsigned n, m, value;
    std::cin >> n >> m;
    --n;
    std::multiset<unsigned> was;
    std::unordered_set<unsigned> res;

    for (unsigned i = 0; i < m; i++)
    {
        std::cin >> value;

        if (was.count(value) >= n) {
            res.insert(value);     
        } else {
            was.insert(value);
        }
    }
    
    std::cout << res.size() << endl; 
    for (unsigned i : res)
    {
        std::cout << i << ' ';
    }
    return 0;
}

