#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (int& x : v) {
        cin >> x;
    }
    sort(v.begin(), v.end());

    vector<int> res;
    int p = 0;
    while (p < m) {
        int cnt = 1, cur = v[p];
        while (p < m - 1 && v[p + 1] == cur) {
            ++cnt;
            ++p;
        }
        if (cnt >= n) {
            res.push_back(cur);
        }
        if (cnt == 1) {
            ++p;
        }
    }
    cout << res.size() << endl;

    for (int& x : res) {
        cout << x << ' ';
    }
    return 0;
}
