#include <bits/stdc++.h>
using namespace std;

int a[200010];
vector<int> propo;

int main() {
	int n, k, t, ans=0;
	scanf("%i%i", &n, &k);
	for (int i = 0; i < n; ++i)
	{
		scanf("%i", &t);
		if (++a[t+n] == k)
		{
			ans++;
			propo.push_back(t);
		}
	}
	cout << ans << endl;
	for (auto it: propo)
		printf("%i ", it);
	return 0;
}