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

int main(){

    long long n, k, p;
    cin >> n >> k;

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

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

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

    return 0;
}