#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include <time.h>
#include <queue>
#include <unordered_set>
#include <fstream>
#include <set>
#include <unordered_map>

using namespace std;
#define ll long long

ll binpow (ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)
			res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}


void fc (){
	ll n,m;
	cin>>n>>m;
	ll a[m+1];
	map <ll,ll> mp;
	for (int i=0; i<m; i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	vector <ll> ans;
	for (int i=0; i<m; i++){
		if (mp[a[i]]>=n){
			ans.push_back(a[i]);
			mp[a[i]]=0;
		}
	}
	
	cout<<ans.size()<<"\n";
	for (int i=0; i<ans.size(); i++){
		cout<<ans[i]<<" ";
	}
	
}


int main (){
	
	
	int T=1;
	//cin>>T;
	while (T--)  fc();
  
  
  
}
