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


int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> cnt(1e9 + 1);
    vector<int> ans;
    while (m--) {
        cin >> a;
        cnt[a]++;
        if (cnt[a] >= n) {
            cnt[a] = -1e9;
            ans.push_back(a);
        }
    }
    cout << ans.size() << endl;
    for (auto u: ans) {
        cout << u << " ";
    }
}
