#include<iostream>
using namespace std;
int main(){
    int n,k,l=0,i;
    cin>>n>>k;
    int x[n],b[2*n+1],y[2*n+1];
    for(i=1;i<=n;i++)
        cin>>x[i];
    for(i=1;i<=2*n+1;i++)
        b[i]=0;
    for(i=1;i<=n;i++)
        if(++b[x[i]+n+1]==k)
            y[++l]=x[i];
    cout<<l<<endl;
    for(i=1;i<=l;i++)
        cout<<y[i]<<" ";
    return 0;
}