#include <iostream>
#include <set>
#define NMAX 1000000
using namespace std;

int N, K, a[NMAX], br[NMAX], c[NMAX], broj;

set<int> s;
set<int>::iterator it;
pair<set<int>::iterator, bool> par;

main(){	

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> N >> K;
	
	for(int i=0; i<N; i++) {
		cin >> a[i];
		par = s.insert(a[i]);
		if(par.second == true) 
			br[a[i]] = 1;
		else {
			br[a[i]]++;
		}
	}
	
	for(it = s.begin(); it != s.end(); it++)
		if (br[*it] >= K) c[broj++]=*it;
		
	if (broj == 0) cout << 0;
	else {
		cout << broj << endl;
		for (int i=0; i<broj; i++)
			cout << c[i] << " ";
	}
	
}