#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int a[100000],i,n,k,br,c;
	int b[100000];
	cin>>n;
	cin>>k;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	
	sort(a,a+n);
	c=0;
	for(i=0;i<=n;i++){
		br=1;
		while (a[i]==a[i+1]){
			br++;
			i++;	
			
		}
		if(br>=k){
			c=c+1;
			b[c]=a[i-1];	
		}
		
		
	}
	cout<<c-1;
	cout<<endl;
	for(i=1;i<c;i++){
		cout<<b[i];
		cout<<' ';
	}
}