#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long;
using db = double;

void solve() {
	int n, m;
	cin >> n >> m;
	map<int, int>mp;
	for (int i = 0; i < m; ++i) {
		int x; cin >> x;
		mp[x]++;
	}
	vector<int>ans;
	for (auto c : mp) {
		if (c.second >= n)ans.push_back(c.first);
	}
	cout << ans.size() << "\n";
	for (auto c : ans)cout << c << " ";
} 

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