#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    map<int, int> mapa;

    for (int i = 0; i < n; i++) {
        int ulaz;
        cin >> ulaz;
        mapa[ulaz] = mapa[ulaz] + 1;
    }


    int counter = 0;
    map<int, int>::iterator itr;
    for (itr = mapa.begin(); itr != mapa.end(); ++itr) {
        if (itr->second >= k) {
            //cout << itr->first << " ";
            counter++;
        }
    }

    cout << counter << endl;
    for (itr = mapa.begin(); itr != mapa.end(); ++itr) {
        if (itr->second >= k) {
            cout << itr->first << " ";
        }
    }
    return 0;
}