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

map<ll, ll> m;

int main()
{
    ll n, k; cin >> n >> k;

    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        m[x]++;
    }

    // Calculate
    ll zaPopravljanje = 0;
    vector<ll> sol;

    for (auto it = m.begin(); it != m.end(); ++it) {
        if (it->second >= k) {
            ++zaPopravljanje;
            sol.push_back(it->first);
        }
    }

    cout << zaPopravljanje << endl;
    for (auto s : sol)
        cout << s << " ";

    return 0;
}