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

int sadrzi(int *a, int n, int br)
{
    for (int i=0;i<n;i++)
    {
        if (a[i]==br) return i;
    }
    return 0;
}

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n];
    int *p=(int*) calloc (n,sizeof(int));
    for (int i=0;i<n;i++)
    {
        scanf("%d",&(a[i]));
        int x=sadrzi(a,n,a[i]);
        if (x!=0) p[x]+=1;
        else p[i]=1;
    }
    int br=0;
    for (int i=0;i<n;i++)
    {
        if (k<=p[i]) br++;
    }
    printf("%d\n",br);
    for (int i=0;i<n;i++)
    {
        if (k<=p[i]) printf("%d ",a[i]);
    }
}