#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin >> n >> m;
	vector<int> num;
	vector<int> answer;
	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		num.push_back(a);
	}
	sort(num.begin(),num.end());
	int count = 1;
	int last = num[0];
	for(int i = 1; i < m; i++){
		if(num[i]==last) count++;
		else{
			if(count >= n) answer.push_back(last);
			count = 1;
		}
		last=num[i];
	}
	if(count >= n) answer.push_back(last);
	cout << answer.size() << '\n';
	for(auto x : answer){
		cout << x << ' ';
	}
}