#include<iostream>
#include<vector>
int main() {
	std::vector<long long>niz;
	std::vector<long long>p;
	std::vector<long long>kol;
	int n, k, br;
	std::cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		std::cin >> br;
		niz.push_back(br);
	}
	int raz = 0, brojac = 0;;
	for (int i = 0; i < n; i++)
	{
		
		br = 0;
		if (niz[i] != 1000007)
		{
			for (int j = i+1; j < n; j++)
			{
				
				if (niz[j] == niz[i])
				{
					br++; 
					niz[j] = 1000007;
				}
			}
		
			br++;
			p.push_back(niz[i]);
			kol.push_back(br);
			raz++;
			if (br >= k)
				brojac++;
		}	
	}

	std::cout << brojac << std::endl;
	for (int i = 0; i < raz; i++)
	{
		if (kol[i] >= k)
			std::cout << p[i] << " ";
	}
	//system("pause");
	//return 0;
}