#include <iostream>
#include <vector>
#include <algorithm>

//#define DEBUG

using namespace std;

int main()
{
    int n, k;
    int br = 0;
    cin >> n >> k;
    int ulaz;
    vector<int> res;
    vector<int> polja(n*2+1, 0);
    for(int i = 0; i < n; ++i){
        cin >> ulaz;
        ++polja[ulaz + n];
        if(polja[ulaz + n] == k){
            res.push_back(ulaz);
        }
    }
    int s = res.size();
    cout << s << endl;
    for(int i = 0; i < s; ++i){
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}