#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
void solve(){
	int n, m; cin >> n >> m;
	vector<int> v(m);
	unordered_map<int, int> mp;
	for(auto &to : v) cin >> to, mp[to]++;
	unordered_map<int, int>::iterator it = mp.begin();
	vector<pair<int, int>> p;
	while(it != mp.end()){
		p.emplace_back(it -> ff, it -> ss);
		it++;
	}
	reverse(p.begin(), p.end());
	vector<int> res;
	for(auto to : p){
		if(to.ss >= n){
			res.emplace_back(to.ff);
		}
	} cout << res.size() << "\n";
	for(auto to : res) cout << to << " ";
}
int main (){
	int test = 1; //cin >> test;
	while(test--) solve(), cout << "\n";
}
