#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl "\n"
#define ll long long
#define int ll
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const ll N=2e5+5,INF=1e18,mod=1e9+7;
void solve(){
	int n,m;cin>>n>>m;
	vector<int> v(m);
	for(int i=0;i<m;i++) cin>>v[i];
	sort(all(v));
	int cnt=0;
	vector<int> ans;
	for(int i=0;i<m;i++){
		if(i==0) cnt++;
		else if(v[i]==v[i-1]) cnt++;
		else cnt=1;
		if(cnt==n) ans.pb(v[i]);
	}
	cout<<ans.size()<<endl;
	for(auto it: ans) cout<<it<<' ';
}
main(){
	ios;
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

