#include <iostream>
#include <set>
#define NMAX 1000001
using namespace std;
int a[NMAX], br[NMAX], n,m,k=0;
set<int> s;
set<int>::iterator it;
pair<set<int>::iterator, bool> par;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		par=s.insert(a[i]);
		if(par.second==true) br[a[i]]=1;
		else 
		{
			br[a[i]]++;	
		}
	}
	for(it=s.begin(); it!=s.end(); it++) 
		if(br[*it]>=m)
			k++;
	cout<<k<<endl;
	for(it=s.begin(); it!=s.end(); it++) 
		if(br[*it]>=m)
			cout<<*it<<" ";
}