// https://www.geeksforgeeks.org/traversing-a-map-or-unordered_map-in-cpp-stl/
#include <bits/stdc++.h> 
using namespace std;

int main()
{
	int t, k;
	cin >> t >> k;
	int arr[t];
	for (int i = 0; i < t; ++i) {
		cin >> arr[i];
	}
	int brojac = 0;
	int res[t];
	
	int n = sizeof(arr) / sizeof(arr[0]);
	map<int, int> m;
	for (int i = 0; i < n; i++)
		m[arr[i]]++;

	for (auto i = m.begin(); i != m.end(); i++)
		if (i->second >= k) {
			res[brojac] = i->first;
			brojac++;
		}
	cout << brojac << endl;
	for (int i=0; i < brojac; ++i)
		cout << res[i] << ' ';

	return 0;
}