#include <bits/stdc++.h>
using namespace std;

#define int long long
#define vi vector <int>
#define speed ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

signed main(){
	int n, m, p = 1, c = 1, cp = 1;
	cin >> n >> m;
	vector <int> a(m), b;
	for (int i = 0; i < m; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < m - 1; ++i){
		if (a[i] == a[i + 1]) c++;
		if (c >= n){
			b.push_back(a[i]);
		}
		if (a[i] != a[i + 1]) c = 1;
	}
	for (int i = 0; i < b.size() - 1; ++i){
		if (b[i] != b[i + 1]) p++;
	}
	cout << p << "\n" << b[0] << " ";
	for (int i = 1; i < b.size(); ++i){
		if (b[i] != b[i + 1]){
			cout << b[i + 1] << " "; cp++;
		}
		if (cp == p){
			break;
		}
	}
}
