#include <iostream>
using namespace std;

int N;
int K;
int i=0;
int l=0;

int main()
{
cin >> N;
cin >> K;
int niz[N];
int res[N/K];
for(int z=0; z<N;z++){  cin >> niz[z];  }
while (i<N){
    int e=i+1;
    if (niz[i]<=N){
    int m=1;
    while (e<N){
        if (niz[i]==niz[e]){
            m++;
            niz[e]=N+1;
        }
        e++;}
    if (m>=K){res[l]=niz[i];l++;}
    }
    i++;
}
cout << l << endl;
for (int h=0;h<l;h++){cout << res[h] << " ";}
return 0;
}