#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){	
	vector <ll> a(10000000,0);
	vector <ll> b;
	int n, m;
	cin >> n >>m;
	int temp, maxi = 0;
	int count=0;
	for (int i = 0 ; i != m ; i++){
		cin>>temp;
		a[temp]++;
		if (temp > maxi ){
			maxi = temp;
		}
	}
	for (int i =0; i <= maxi; i++){
		if (a[i] >= n){
			b.push_back(i);
			count ++;
		}
	}
	cout << count<<"\n";
	for (int i =0; i<b.size();i++){
		cout<<b[i]<<" ";
	}
}

