#include <iostream>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define MAXN 200
int main(int argc, char** argv) {
	int a[MAXN];
	long long n,k,b[MAXN],i,brojac,brojac2=0,brojac3=0,j;
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>a[i];	
	}
	sort(a,a+n);
	for(i=0;i<n-1;i++){
		brojac=0;
		while(a[i]==a[i+1]){
			brojac++;
			i++;
		}
		if(brojac+1>=k){
			brojac2++;
			b[brojac3]=a[i];
			brojac3++;
		}
		
	}
	cout<<brojac2<<endl;
	for(i=0;i<brojac3;i++){
		cout<<b[i]<<" ";
	}
	
	return 0;
}