#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k,niz[100000],brojac[100000],rez[100000],br=0;
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>niz[i];
for(int i=0;i<n;i++)
{
brojac[niz[i]]++;
if(brojac[niz[i]]==k)
{
rez[br]=niz[i];
br++;
}
}
sort(rez,rez+(br-1));
cout<<br<<endl;
for(int i=0;i<br;i++)
cout<<rez[i]<<" ";
cout<<endl;
return 0;
}