#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	ll n, m, res = 0;
	vector <ll> p;
	cin>>n>>m;
	ll a[m] = {};
	map <ll, ll> qwti;
	for(ll i = 0; i < m; i++){
	    cin>>a[i];
	    qwti[a[i]]++;
	}
	for(auto it = qwti.begin(); it != qwti.end(); it++){
	    if((it->second)>=n){
	        res++;
	        p.push_back((it->first));
	    }
	}cout<<res<<"\n";
	for(ll i = 0; i < res; i++){
	    cout<<p[i]<<" ";
	}
}