#include<iostream>
#include <vector> 

using namespace std;

int main()
{
	int n,k;
	cin>>n>>k;
	int niz[2*n+1]={0};
	vector<int> niz_zamena; 
	
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		niz[t+n]++;
		if(niz[t+n]==k)
			niz_zamena.push_back(t);
	}
	cout<<niz_zamena.size()<<endl;
	for (auto i = niz_zamena.begin(); i != niz_zamena.end(); ++i) 
        cout << *i << " "; 
}