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

using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> brojevi;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a, a+n);
	int brojac=0;
	for(int i=1; i<n; i++)
	{
		if(a[i]==a[i-1])
		{
			brojac++;
		}
		if(brojac>=k)
		{
			brojevi.push_back(a[i]);
		}
	}
	cout<<brojevi.size()<<endl;
	for(int i=0;i<brojevi.size();i++)
	{
		cout<<brojevi[i]<<" ";
	}
	
	return 0;
}