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

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

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


    map<int, int>::iterator itr;

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