#include <iostream>

#include <vector>

using namespace std;

//zadatak a
int main() {
	int i, j,b;
	int n, k;
	int temp;
	bool f;
	
	vector<int> arr;
	vector<int> r;
	vector<bool> fnd;

	b = 1;
	

	cin >> n >> k;

	for (i = 0; i < n; i++) {
		cin >> temp;
		arr.push_back(temp);
		fnd.push_back(0);
	}

	for (i = 0; i < n; i++) {
		f = 0;
		b = 1;
		if (fnd[i] == 0) {

			for (j = i + 1; j < n; j++) {
				if (arr[i] == arr[j]) {
					f = 1;
					b++;
					fnd[i] = 1;
					fnd[j] = 1;
				}
			} 
			if (f == 1) {
				if (b >= k) {
					r.push_back(arr[i]);
				}
			}

		}  //  if found
	}// for i


	cout << r.size() << endl;
	for (i = 0; i < r.size(); i++) {
		cout << r[i] << ' ';
	}
	return 0;
}