#include<bits/stdc++.h>

using namespace std;
using ll = long long;

ll f(int w, int h) {
    if (w == 1 && h == 1)return 1;
    ll res = 0;
    for (int l = 1;l < w;l++)res = max(res, f(l, h) + f(w - l, h) + w * h);
    for (int l = 1;l < h;l++)res = max(res, f(w, l) + f(w, h - l) + w * h);
    return res;
}
ll cnt = 0;
ll f2(int w, int h) {
    cnt++;
    assert(cnt <= 1e7);
    if (h > w)swap(h, w);
    if (w == 1ll && h == 1ll)return 1ll;
    ll res = w * h + f2(w - 1, h) + f2(1, h);
    return res;
}
int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, int> cnt;
    while(m--) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    set<int> ans;
    for(auto p : cnt) {
        int x, y;
        tie(x, y) = p;
        if(y >= n) {
            ans.insert(x);
        }
    }
    cout << (int)ans.size() << "\n";
    for(auto x : ans) {
        cout << x << ' ';
    }
    return 0;
}
