#include <bits/stdc++.h>
using namespace std;
int n,a[2000007],k,b,res[2000007],br;
int main () {
scanf("%d%d",&n,&k);
for (int i=1;i<=n;i++){
    scanf("%d",&b);
    a[b+n]++;
}
for (int i=0;i<=2*n;i++){
    if (a[i]>=k){
        br++;
        res[br]=i-n;
    }
}
printf("%d\n",br);
for (int i=1;i<=br;i++){
    printf("%d ",res[i]);
}
printf("\n");
return 0;
}