#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long n, k, p;
    cin >> n >> k;

    map<long long, long long> meta;
    vector<long long> res;
    while (n--){
        cin >> p;
        meta[p]++;
    }

    for (auto i : meta){
        if (i.second >= k)
            res.push_back(i.first);
    }

    cout << res.size() << endl;
    for (auto i : res)
        cout << i << " ";
    cout << endl;

    return 0;
}