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