#include <iostream>
#include <unordered_map>

using namespace std;

int main()	{
	
	unordered_map<long, long> map;
	
	long *r = new long[(long)1e6+1];
	
	long N, K, c=0;
	cin>>N>>K;
	
	long x=0;
	for(long i=0; i<N; i++){
		cin>>x;
		map[x]++;
	}
	
	for(auto it : map){
		if(it.second>=K){
			r[c]=it.first;
			c++;
		}
	}
	
	cout<<c<<"\n";
	for(long i=0; i<c-1; i++)
		cout<<r[i]<<' ';
	cout<<r[c-1];
	
	delete [] r;
	return 0;
}