#include <bits/stdc++.h>
using namespace std;
long long arr[10000000],n, k, c, br = 0, niz2[10000000];
map <int, int> bp;
int main() {
cin >> n >> k;
arr[n+1] = n+1;
for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    bp[arr[i]]++;
}


sort(arr+1, arr+n+1);
for (int i = 1; i <= n; i++) {
    if (arr[i] != arr[i+1] and bp[arr[i]] >= k) {
    //cout << arr[i] << " - " << bp[arr[i]] << endl;
        br++;
    }
}

cout << br << endl;
for (int i = 1; i <= n; i++) {
    if (arr[i] != arr[i+1] and bp[arr[i]] >= k) {
        cout << arr[i] << " ";
    }
}

return 0;
}