#include <iostream>
#include <vector>
#include <unordered_map>
#include <set>

using namespace std;

int main()
{
	long n, k;
	cin >> n >> k;
	vector<long> fields(n);//Input values
	unordered_map<long, long> map;//Map with field to hits mapping
	set<long> s;//Set with all fields that you need to replace

	for (long i = 0; i < n; i++) {
		//Input the values
		cin >> fields[i];
		//Save them to the map and count how many shots hit it
		map[fields[i]]++;
	}

	//Count ones that are bigger than k
	long count = 0;
	for (auto x : map) {
		if (x.second >= k) {
			//and add them to set
			s.insert(x.first);
			count++;
		}
	}

	//Number of fields to replace
	cout << count << endl;
	//Which fields to replace
	for (auto x : s) {
		cout << x << " ";
	}
	cout << endl;
}