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

//#define pb push_back;

map <int, int> mm;
map <int, bool> was;

void solve() {
	int n, m;
	cin >> n >> m;
	
	vector <int> ans;
	for (int i = 1; i <= m; ++i) {
		int x; cin >> x;
		mm[x]++;
		if(mm[x] >= n and !was[x]) {
			ans.push_back(x);
			was[x] = true;
		}
			
	}
	
	cout << ans.size() << "\n";
	for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int T = 1;
//	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
