#include <bits/stdc++.h>

using namespace std;

int main()
{
    int h=0,n,k,g;
    scanf("%d %d",&n,&k);
    int a[2*n+1]={0};
    for (int i=0;i<n;i++){
        scanf("%d",&g);
        g+=n;
        if (a[g]!=-1)
        a[g]++;
        if (a[g]==k){
            h++;
            a[g]=-1;
        }
    }
    printf("%d\n",h);
    for (int i=0;i<=2*n;i++){
        if (a[i]==-1)
            printf("%d ",i-n);
    }
    printf("\n");
    return 0;
}