#include <iostream>

using namespace std;

int main()	{
	
	long *f = new long[(long)2e6+1];
	long *r = new long[(long)1e6+1];
	
	long N, K, c=0;
	cin>>N>>K;
	
	
	long *p = &f[N];
	
	long x=0;
	for(long i=0; i<N; i++){
		cin>>x;
		p[x]++;
	}
	
	for(long i=-N; i<N; i++){
		if(p[i]>=K){
			r[c]=i;
			c++;
		}
	}
	
	cout<<c<<"\n";
	for(long i=0; i<c; i++)
		cout<<r[i]<<' ';
	
	
	delete [] f;
	delete [] r;
	return 0;
}