#include <iostream>

using namespace std;

int main()
{
    int temp;
    int br = 0;
    int N, K;
    cin >> N >> K;

    int A[N];
    for (int i = 0; i < N; ++i)
        cin >> A[i];

    int Hit[2 * N + 1];
    int Replace[2 * N + 1];
    for (int i = 0; i < 2 * N + 1; ++i){
        Hit[i] = 0;
        Replace[i] = 0;
    }

    for (int i = 0; i < N; ++i){
        temp = A[i] + N;
        ++Hit[temp];
    }

    for (int i = 0; i < 2 * N + 1; ++i){
        if (Hit[i] >= K){
            ++br;
            Replace[i] = 1;
        }
    }

    cout << br << endl;
    for (int i = 0; i < 2 * N + 1; ++i){
        if (Replace[i] == 1)
            cout << i - N << " ";
    }

    return 0;
}