#include <bits/stdc++.h>

using u32 = unsigned int;

int main()
{
	u32 n, k;
	std::scanf("%u %u", &n, &k);
	
	auto hash = [&n](int x) -> u32 {
		return n + x;
	};

	u32 ponavljanja[2 * 1'000'000 + 1];
	
	for (int i = 0; i < 2 * n + 1; ++i)
		ponavljanja[i] = 0;
	
	u32 count = 0;
	for (int i = 0; i < n; ++i)
	{
		int val;
		std::scanf("%d", &val);
		++ponavljanja[hash(val)];
	}

	auto rhash = [&n](u32 x) -> int {
		return x - n;
	};
	for (int i = 0; i < 2 * n + 1; ++i)
		if (ponavljanja[i] >= k)
			++count;
	std::printf("%d\n", count);

	for (int i = 0; i < 2 * n + 1; ++i)
		if (ponavljanja[i] >= k)
			std::printf("%d ", rhash(i));

	return 0;	

}