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

int main()
{
	int n, k,output_array_elements;
	int i,temp,counter;
	std::vector<int> input_array,output_array;

	std::cin >> n;
	std::cin >> k;

	for (i = 0; i < n; i++) {
		std::cin >> temp;
		input_array.push_back(temp);
	}

	std::sort(input_array.begin(), input_array.end());

	temp = input_array[0];
	counter = 1;
	for (i = 1; i < n; i++) {
		if (input_array[i] == temp) {
			counter++;
		}
		else {
			if (counter >= k) {
				output_array.push_back(temp);
			}
			counter = 1;
			temp = input_array[i];
		}
	}
	
	if (counter >= k) {
		output_array.push_back(temp);
	}

    std::cout << output_array.size()<<std::endl;

	output_array_elements = output_array.size();

	for (i = 0; i < output_array_elements; i++) {
		std::cout << output_array[i]<< " ";
	}
}