#include <iostream>
#include <set>
#define NMAX 1000000
using namespace std;
int a[NMAX], br[NMAX], n, k,max_nr = 0;
set<int> s,pos;
set<int>::iterator it;
pair<set<int>::iterator, bool> par;
int 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)
		{
			max_nr++;

		}
	}
	cout << max_nr << endl;
	for (int i = 0; i < n; i++)
	{
		if (br[a[i]] >= k)
		{
			pos.insert(a[i]);
		}
	}
	for (it = pos.begin(); it != pos.end(); it++) cout << *it << " ";

	return 0;
}