#include <bits/stdc++.h>

using namespace std;

#define ll long long

map <int , int> mp;
set <int> st;

void solve(){
	ll n , m;
	cin >> n >> m;
	ll a[m+9];
	for (int i = 1 ; i <= m ; i++){
		cin >> a[i];
		st.insert(a[i]);
		mp[a[i]]++;
	}
	vector <int> v;
	for (auto to : st){
		if (mp[to]>=n)v.push_back(to);
	}
	cout << v.size() << "\n";
	for (auto to : v)cout << to << " ";
}

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