#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
 
#define pb push_back
#define ll long long
#define f first
#define s second

const ll int INF = 1e18, inf = 1e9, mod = 1e9 + 7;


using namespace std;



int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	map<int, int> mp;
	int n, m, c, ans = 0;
	cin>>n>>m;
	set<int> st;
	for (int i = 0; i< m; ++i) {
		cin>>c;
		mp[c]++;
	}
	map <int, int> :: iterator it = mp.begin();
	for (int i = 0; it != mp.end(); it++, i++) {
		if (it->s >= n) {
			ans++;
			st.insert(it->f);
		}
	}

	cout<<ans<<"\n";

	set <int> :: iterator t = st.begin();
	for (int i = 0; t != st.end(); t++, i++) {
		cout<<*t<<" ";
	}
}
