#include <cstdio>
#include <map>
#include <set>

using namespace std;

int main() {
	map<long, long> mapa;
	set<long> myset;
	long n, k;
	scanf("%li%li", &n, &k);
	for (int i = 0; i < n; i++) {
		long num;
		scanf("%li", &num);
		if (mapa.find(num) == mapa.end())
			mapa.insert(make_pair(num, 1));
		else {
			mapa[num]++;
			if (mapa[num] >= k)
				myset.insert(num);
		}
	}
	printf("%li\n", myset.size());
	for (auto it = myset.begin(); it != myset.end(); it++) {
		printf("%li ", *it);
	}
	return 0;
}