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

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