#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m, i, j, a[300001];
map<int, int> mp;
set<int> ans;
 
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
	swap(n, m);
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		mp[a[i]]++;
	}
	for (i = 1; i <= n; i++) {
		if (mp[a[i]] >= m) ans.insert(a[i]);
	}
	cout << ans.size() << "\n";
	for (int i : ans) cout << i << " ";
}