 #include<bits/stdc++.h>
 #include <algorithm>
 #include <math.h>
using namespace std;
 #define  SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 #define str string
 #define pb push_back
 #define nl "\n"
 #define ll long long
 #define all(v) (v).begin(), (v).end()
 #define rall(v) (v).rbegin(), (v).rend()
 #define F first
 #define S second
 #define len(a) a.size()
 #define sz(v) (int)(v.size())
 #define pii pair<int,int>
const int N=2e3+3;
const int mx=2e3+12;
const int mega=1e6+3;
void solve(){
int n,m;
cin>>n>>m;
vector<int>vec(m+1);
map<int,int>mp;
for(int i=1;i<=m;i++){
	cin>>vec[i];
	mp[vec[i]]++;
}
vector<int>v;
for(int i=1;i<=m;i++){
	if(mp[vec[i]]>=n){
		v.pb(vec[i]);
		mp[vec[i]]=0;
	}
}
cout<<v.size()<<endl;
for(int i=0;i<v.size();i++)cout<<v[i]<<" ";
}
signed main(){
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
while(t--){
    solve();
}
}
