#include <iostream>
#include <fstream>

using namespace std;

long long int n, k, niz[10000000], a, nula = 5000000, konacno[10000000], kn = 1, ukupno;

int main(){
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
	//cout << "2000001 1\n";
	//for(int i = -1000000; i <= 1000000; i++) cout << i << " ";
	//cout << endl;
	
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> a;
		niz[a+nula]++;
	}
	//for(int i = 0; i <= 20000000; i++) cout << niz[i] << " ";
	for(int i = -1000005; i <= 1000005; i++){
		if(niz[i+nula] >= k){
			konacno[kn] = i; kn++;
			ukupno++;
		}
	}
	cout << kn-1 << endl;
	for(int i = 1; i < kn; i++){
		cout << konacno[i] << " ";
	}
	
	return 0;
}