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

using namespace std;

int main(int argc, char** argv)
{
	unsigned long long int N, a = 0, K;
	long long int b;
	map<long long int, unsigned long long int> m;
	vector<long long int> v;
	map<long long int, unsigned long long int>::iterator l;
	
	cin >> N >> K;
	
	for(unsigned long long int i = 0; i < N; i++)
	{
		cin >> b;
		m[b]++;
	}
	
	for(l = m.begin(); l != m.end(); l++)
	{
		if(l->second >= K)
		{
			a++;
			v.push_back(l->first);
		}
	}
	
	cout << a << endl;
	for(unsigned long long int i = 0; i < v.size(); i++)
	{
		cout << v[i] << " ";
	}
	cout << endl;
	
	return 0;
}