#include<bits/stdc++.h>
using namespace std;
int main() {
    long long a,b;
    cin >> a >> b;
    long long c[b];
    map<long long,long long>mp;
    map<long long,long long>mp1;
    for (long long i = 0 ; i < b; i ++) {
        cin >> c[i];
        mp[c[i]]++;
    }
    long long k=0;
    vector<long long>ans;
        for(long long i=0;i<b;i++){
        if (mp[c[i]]>=a&&mp1[c[i]]!=1) {
                ans.push_back(c[i]);
                mp1[c[i]]=1;
        }
    }
    cout<<ans.size()<<endl;
    for(long long i=0;i<ans.size();i++) {
        cout<<ans[i]<<" ";
    }
}
