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

int main()
{
    int n,k,br=0,p;
    vector <int> v;
    cin >> n >> k;
    int a [2*n+1]={};
    int l []={};
    for (int i = 0; i < n; i++) {
        cin>>p;
        a[p+n]+=1;
        if(a[p+n]==k){
            br++;
            v.push_back(p);
        }
    }
    cout<<br<<endl;
    for(int i=0; i<v.size(); ++i)
    cout << v[i] << ' ';
    return 0;
}