#include <bits/stdc++.h>

using namespace std;


typedef vector<int> vi;


#define EB emplace_back


// global variables:
int N, K;
vi HITS;


// functions:
void input();
void Solve();
void output(vi vct);


int main()
{
    //freopen("input.txt", "r", stdin);

    input();
    Solve();

    return 0;
}


void Solve() {
    vi memo(2 * N + 1);  // keeps track of hit positions
    vi targets_to_replace;

    // store number of hits per target:
    for (int i = 0; i < N; ++i) {
        int cur_hit = HITS[i];
        ++memo[cur_hit + N];  // increase # of hits of cur target

        if (memo[cur_hit + N] == K) {
            targets_to_replace.EB(cur_hit);
        }
    }

    output(targets_to_replace);
}


void output(vi vct) {
    printf("%d\n", vct.size());
    for (auto it = vct.begin(); it != vct.end(); ++it) {
        printf("%d ", (*it));
    }
    printf("\n");
}


void input() {
    scanf("%d %d\n", &N, &K);

    // allocate space and assign zeros:
    HITS.resize(N);

    for (int i = 0; i < N; ++i) {
        scanf("%d", &HITS[i]);
    }
}