#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, m, k = 1;
	cin >> n >> m;
	int a[m];
	for (int i = 0; i < m; ++ i)
		cin >> a[i];
	sort(a, a + m);
/*	for (int i = 0; i < m; ++ i)
		cout << a[i] << " ";
	cout << endl;*/
	vector<int> v;
	for (int i = 1; i < m ; ++ i)
	{
		if (a[i] == a[i - 1])
			++ k;
		else
			{
				if (k >= n) v.push_back(a[i-1]);
				k = 1;
			}
	}
	if (k >= n) v.push_back(a[m - 1]);
	cout << v.size() << endl;
	for (int x:v)
		cout << x << " ";
return 0;
}