#include <iostream>
#include <set>
using namespace std;

int main() {
	long n, brojMenjanjaPolja, brojac = 0;
	set <long> filter;

	cin >> n >> brojMenjanjaPolja;
	long *a = new long[n];
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < n; i++) {

		for (int j = 0; j < n; j++) {
			if (a[i] == a[j]) brojac++;
		}
		if (brojac >= brojMenjanjaPolja) filter.insert(a[i]);
		brojac = 0;
	}

	cout << filter.size() << endl;
	for (auto it = filter.begin(); it != filter.end(); ++it)
		cout << *it << ' ';
	system("pause");
	return 0;
}