#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,i,j,count,k,br=0;
    cin>>n>>k;
    int a[n];
    int freq[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        freq[i]=-1;
    }
    for(int i=0;i<n;i++)
    {
        count=1;
        for(int j=i+1;j<n;j++)
        {
            if(a[i]==a[j])
            {
                count++;
                freq[j]=0;
            }
        }
        if(freq[i]!=0)
        {
            freq[i]=count;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(freq[i]!=0)
        {
            if(freq[i]>=k)
            {
                br++;
            }
        }
    }
    cout<<br<<endl;
     for(int i=0;i<n;i++)
    {
        if(freq[i]!=0)
        {
            if(freq[i]>=k)
            {
                cout<<a[i]<<" ";
            }
        }
    }
    return 0;
}