#include <bits/stdc++.h>
  
#define int long long
  
using namespace std;
 
main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
	cin >> n >> m;
	map<int, int> us;
	int c[m + 5];
	for(int i = 1; i <= m; ++i) {
		cin >> c[i];
		us[c[i]] ++;
	}
	vector<int> ans;
	for(int i = 1; i <= m; ++i) {
		if(us[c[i]] >= n) {
			ans.push_back(c[i]);
			us[c[i]] = 0;
		}
	}
	cout << ans.size() << "\n";
	for(int to : ans) {
		cout << to << " ";
	}
}
