
#include<bits/stdc++.h>
using namespace std;

#define ll long long

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	ll n,m;
	cin>>n>>m;
	vector<long long> v(m);
	set<ll> numbers;
	
	for (int i =0; i<m; i++){
	    int temp =0;
	    cin>>temp;
	    v[i]=temp;
	    numbers.insert(temp);
	}
	
	map<ll,ll> da;
	long long maxx=0;
	
	for(auto t : v){
	    da[t]++;
	    maxx=max(maxx,t);
	}
	
	vector<ll> two;
	long long cnt = 0;
	
	
	for(auto t : numbers){
	    if (da[t] >= n){
	        
	        two.push_back(t);
	        cnt++;
	    }
	    
	}
	cout<<cnt<<endl;
	for(auto t : two){
	    cout<<t<<' ';
	}
	
}