#include <iostream>

using namespace std;
int main(){
    int brlp,N,K,br;
    brlp=0;
    cin>>N>>K;
    int A[N],nizisk[N];
    for(int i = 1; i <= N; i++){
        cin>>A[i];
        //cout<<"A["<<i<<"]="<<A[i]<<endl;

    }
    int N1 = N * (-1);
    //Sad krece cudoviste 1
    for(int iisk=1;iisk<=N;iisk++){
        nizisk[iisk]=N+1;
        //cout<<"ns["<<iisk<<"]="<<nizisk[iisk]<<endl;
    }


    for(int j = 1; j <= N; j++){
        bool isto = false;
        br=0;
        for(int iisk2=1;iisk2<=N;iisk2++){
            if(A[j]==nizisk[iisk2]){
                isto=true;
            }
        }
        if(!isto){
            nizisk[j]=A[j];
            //cout<<"usao if za iskoriscene"<<endl;
            for(int p = j; p <= N; p++){
            if(A[p] == A[j]){
                br++;
            }
        }
        if(br >= K){
            brlp++;
            //nizisk[j]=A[j];
        }
        }


    }
    cout<<brlp<<endl;


    for(int jisk=1;jisk<=N;jisk++){
        nizisk[jisk]=N+1;
        //cout<<"ns["<<iisk<<"]="<<nizisk[iisk]<<endl;
    }
    for(int j1 = 1; j1 <= N; j1++){
        bool isto = false;
        br=0;
        for(int jisk2=1;jisk2<=N;jisk2++){
            if(A[j1]==nizisk[jisk2]){
                isto=true;
            }
        }
        if(!isto){
           nizisk[j1]=A[j1];
            //cout<<"usao if za iskoriscene"<<endl;
            for(int p1 = j1; p1 <= N; p1++){
            if(A[p1] == A[j1]){
                br++;
            }
        }
        if(br >= K){
            cout<<A[j1]<<" ";
            //nizisk[j]=A[j];
        }
        }

}
}