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

map<long long,long long> mapa;
vector <long long> vektor;
long long k,i,j,n,br=0,jeste;
int main(){
	scanf("%lld%lld",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%lld",&jeste);
		mapa[jeste]+=1;
		if(mapa[jeste]==k){
			vektor.push_back(jeste);
			br+=1;
		}
	}
	printf("%lld\n",br);
	for(j=0;j<br;j++)printf("%lld ",vektor[j]);
}