#include <bits/stdc++.h>

using namespace std;

int n,k , res_br, x, duplo;
int a[2000005], res[2000005];

int main() {
    scanf("%d %d", &n , &k);
    if (n == 1 and k == 1){
        cin >> a[1];
        cout << 1 << endl;
        cout << a[1] << endl;
        return 0;
    }
    for (int i = 1; i <= n; i++){
        scanf("%d",&x);
        a[x+n]++;
    }
    duplo = n+n;
    for (int i = 0; i <= duplo; i++){
        //cout << i << endl;
        //cout << a[i] << endl;
        if (a[i] >= k){
            res[res_br++] = i;
            //cout << res[res_br] << " ";
        }
    }
    if (res_br == 0){
        cout << 0 << endl;
    }
    else {
        cout << res_br << endl;
        for(int i = 0; i < res_br; i++){
            cout << res[i]-n << " ";
        }
        cout << endl;
    }

    return 0;
}