#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int N,K,br,t;
    cin >> N >> K;
    int a[N];
    int b[N];
    
    for (int i=0; i<N; i++)
    {
        cin >> a[i];
    }
    
    sort(a,a+N);
    
    int i = 0;
    int j = 0;
    
    while (i<N)
    {
        br=1;
        t=i+1;
       while(a[i]==a[t])
        {
            br++;
            t++;
        }
        if(br>=K)
        {
            b[j]=a[i];
            j++;
        }
        i=i+br;
    }
    
    cout << j << "\n"; 
    for(i=0; i<j; i++)
    {
        cout<<b[i]<<" ";
    }
    
    
    
    
    return 0;
}