#include <iostream>
#include <string>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    int meta[2*N+1] = { 0 };
    string zaZamenu = "";
    int counter = 0;

    for(int i = 0; i < N; i++){
        int x;
        cin >> x;

        meta[x+N]++;
        if(meta[x+N] == K){
            counter++;
            zaZamenu += to_string(x) + " ";
        }
    }

    cout << counter << endl << zaZamenu;

    return 0;
}