#include <bits/stdc++.h>
using namespace std;

int main() {
    long n,k;
    scanf("%ld %ld",&n,&k);
    vector<long> mete;
    vector<long> res;
    mete.resize(2*n+1);
    for (long i=0; i<2*n+1;i++) {
        mete[i]=0;
    }
    long p,br;
    br=0;
    for (long i=0; i<n; i++) {
        scanf(" %ld",&p);
        mete[n+p]+=1;
    }
    for (long i=0; i<2*n+1;i++) {
        if (mete[i]>=k) {
            res.push_back(i-n);
            br+=1;
        }
    }
    printf("%ld\n",br);
    for (long i=0;i<res.size();i++) {
        printf("%ld ",res[i]);
    }
    return 0;
}