#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int k;
	cin >> n>>k;
	vector<int>pogodci(n);
	vector<int>prov(n);
	int counter = 0;
	bool nulali = false;
	int zajmi0 = 0;
	int counto = 0;
	for (int i = 0; i < n; i++) {

		cin >> pogodci[i];
		if (nulali == false) {
			if (pogodci[i] == 0) {

				nulali = true;
				zajmi0 = i;

			}
		}
		if (pogodci[i] == 0) {
			counto++;
		}
	}
	if (nulali == true) {
		counter++;
	}
	
	for (int i = 0; i < n; i++) {


		if (std::count(prov.begin(), prov.end(), pogodci[i])) {

		}
		else {
			int broj = count(pogodci.begin(), pogodci.begin()+n, pogodci[i]);
			if (broj >= k) {
				prov[counter] = pogodci[i];
				
				counter++;

			}


		}

	}
	
	cout << counter<<endl;
	for (int i = 0; i < counter; i++) {

		cout << prov[i]<<" ";
	}

	return 0;
}