#include <iostream>
using namespace std;


int main(int argc, char** argv) {
	int n,k;
	cin >>n>>k;
	int a[n],b,j,d,c[n],x,i;
	x = 0;
	b = 0;
	d = 0;
	j = 0;
	for(i=0;i<n;i = i+1){
		cin >> a[i];
		for(j=0;j<=i;j=j+1){
			if(a[j]==a[i]) b = b+1;
	}
	j = 0;
	if (b>=k) {
		d = d + 1;
		c[x] = a[i];
		x = x + 1;
	}
	} 
	j = 0;
    cout << d << endl;
    for(j=0;j<=x;j=j+1){
    	cout << c[j] << endl;
	}
	return 0;
}