#include <iostream>

using namespace std;

int n,k,t,c = 0,out[1000009],in[2000009];

int main()
{
    std::ios::sync_with_stdio(false);

    cin >> n >> k;

    for(int i = 0;i < n;i++){
        cin >> t;
        in[n + t + 2]++;
            if(in[n + t + 2] == k){
            out[c] = t;
            c++;
        }
    }

    cout << c << endl;
    for(int i = 0;i < c;i++){
        cout << out[i] << " ";
    }

    return 0;
}