#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int pogodak[n],polja[2*n+1]={0},brpolja=0,zabrana[2*n+1]={0};
    vector<int> resenje;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&pogodak[i]);
        polja[pogodak[i]+n]++;
        if(polja[pogodak[i]+n]>=k && zabrana[pogodak[i]+n]!=1)
        {
            brpolja++;
            resenje.push_back(pogodak[i]);
            zabrana[pogodak[i]+n]=1;
        }
    }
    printf("%d\n",brpolja);
    for(int i=0;i<resenje.size();i++)
    {
        printf("%d ",resenje[i]);
    }

}