#include <stdio.h>
#include<stdlib.h>

int uporedi (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main()
{
   
    int n,k,t=0,p,c;
   
    scanf("%d %d",&n,&k);
    int a[n];
    int b[n];
    for(int i=0; i<n; i++)
        scanf("%d",&a[i]);
       
    qsort(a, n, sizeof(int), uporedi);    
   
    for(int i = 0;i<n;i=i+c){
        p=i+1;
        c=1;
        while(a[i]==a[p]){
            c++;
           p++;
           
        }
        if(c>=k){
            b[t]=a[i];
            t++;
           
        }
       
    }
    printf("%d\n",t);
    for(int i=0; i<t; i++)
        printf("%d ",b[i]);
   
   
    return 0;
}