#include<iostream>
#include<vector>
#include<string>	
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

//=================================

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

//=================================

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
		cout << '\n';
	}
	return 0;
}