#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char** argv) {
	
	long long n,k,nlevo,ndesno;
	cin>>n>>k;
	long long b1=0,i2=0,r=0,j2,i3=0;
	vector <long long> l1;
	long long niz [n];
	long long niz1 [n];
	long long niz2 [n];
	/*drugi deo*/
	for(long long i=0;i<n;i++){
		niz1[i]=0;
		cin>>niz[i];	
	}
	for(long long i=0;i<n;i++){
		for (long long j=0;j<l1.size();j++){
			if(niz[i] == l1[j]){
				b1++;
				j2=j;
				break;
			}
		}
		if(b1==0){
			l1.push_back(niz[i]);
			niz1[i2]=1;
			i2++;
		}
		else {
		niz1[j2]++;
		}
		b1=0;	
	}
	for(int i=0;i<l1.size();i++){
		if(niz1[i]>=k){
			r++;
			niz2[i3]=l1[i];
			i3++;	
		}
	}
	cout<<r<<"\n";
	for(int i=0;i<r;i++){
		cout<<niz2[i]<<" ";
	}
	return 0;
}