#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
#include<unordered_set>
#include<unordered_map>
#include<queue>
#include<stack>
#include<deque>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
void solve() {
	int n, m, c;
	cin >> n >> m;
	map<int, int> mp;
	for (int i = 0; i < m; ++i) {
		cin >> c;
		mp[c]++;
	}
	vector<int> ans;
	for (auto p : mp) {
		if (p.second >= n) {
			ans.push_back(p.first);
		}
	}
	cout << ans.size() << '\n';
	for (int e : ans) {
		cout << e << ' ';
	}
}
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}