#include <iostream>
void razmeni (int *a,int *b)
{
    int pom=*a;
    *a=*b;
    *b=pom;
}
void sort1(int a[],int n)
{
    int i,j;
    for(i=0;i<n-1;i++)
        for(j=i+1;j<n;j++)
            {
                if(a[i]>a[j]) razmeni(&a[i],&a[j]);
            }

}
int br(int x,int n,int a[])
{
    int i,brojac=0;
    for(i=0;i<n;i++)
    {
        if(x==a[i]) brojac++;
    }
    return brojac;
}
using namespace std;
int main()
{
    int n,k,a[100000],b[100000];
    int i,j,x=0,brojac=0;
    cin>>n>>k;
    for(i=0;i<n;i++) cin>>a[i];
    sort1(a,n);
    for(i=0;i<n;i+=br(a[i],n,a))
    {
        if(br(a[i],n,a)>=k)
        {
            brojac++;
            b[x]=a[i];
            x++;
        }
    }
    cout<<brojac<<endl;
    for(i=0;i<brojac;i++) cout<<b[i]<<" ";
    return 0;
}