#include <iostream>
#include <vector>
#include <map>

int main()
{
	long long N, K;
	std::cin >> N >> K;
	
	std::vector<long long> v;
	
	long long t;
	
	while (N > 0)
	{
		std::cin >> t;
		v.push_back(t);
		--N;
	}
	
	long long c = 0;
	
	std::vector<long long> replace;
	
	std::map<long long, int> m;
	
	for (const auto& r : v)
	{
		auto s = m.find(r);
		
		if (s != m.end())
		{
			++m.at(r);
		}
		else
		{
			m.insert(std::make_pair(r, 1));
		}
	}
	
	for (const auto& r : m)
	{
		if (r.second >= K)
		{
			++c;
			replace.push_back(r.first);
		}
	}
	
	std::cout << c << std::endl;
	
	for (const auto& r : replace)
	{
		std::cout << r << " ";
	}
	
	return 0;
}