#include <bits/stdc++.h>
using namespace std;


int main()
{
    int n, m, a;
    cin >> n >> m;
    unordered_map<int, int> cnt;
    int ans = 0;
    while (m--) {
        cin >> a;
        cnt[a]++;
    }
    for (auto u: cnt) {
        if (u.second >= n) {
            ans++;
        }
    }
    cout << ans << endl;
    for (auto u: cnt) {
        if (u.second >= n) {
            cout << u.first << " ";
        }
    }
    return 0;
}
