#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector <int> v;
    for(int i = 0; i <= 2 * n; i++){
        v.push_back(0);
    }
    vector <int> polja;
    int brojac = 0;
    for(int i = 0 ; i < n; i++){
        int a;
        cin >> a;
        v[a + n]++;
        if(v[a + n] == k){
            brojac++;
            polja.push_back(a);
            v[a] = 0;
        }
    }
    cout << endl << brojac << endl;
    for(int i = 0; i < brojac; i++){
        cout << polja[i] << endl;
    }
    return 0;
}