#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
int c[b];
map<int,int> cnt;
for(int i=0;i<b;i++){
    cin >> c[i]; 
    cnt[c[i]]++;
}
vector<int> tmp;
for (auto& [first, second] : cnt) {
    if (second >= a) {
        tmp.push_back(first);
    }
}
cout << tmp.size() << endl;
for(int i=0;i<tmp.size();i++){
    cout << tmp[i] << " ";
}
}