#include <iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int bacanja[n];
    int bacanja2[5];
    int brojac[n];
    int z = 0;
    for(int i = 0;i<n;i++){
        cin>>bacanja[i];
        brojac[i] = 1;
    }
    for(int j = 0;j<n;j++){
        for(int m = j+1;m<n;m++){
            if(bacanja[j] == bacanja[m]){
                brojac[j] += 1;
                brojac[m] = -999;
            }
        }
    }
    for(int l = 0;l<n;l++){
        if(brojac[l] >= k){
            z += 1;
            bacanja2[l] = bacanja[l];
        }
    }
    cout<<z<<"\n";
    for(int x = 0;x<z;x++){
        cout<<bacanja2[x]<<" ";
    }
}