#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, K;
    scanf("%d %d", &N,&K);
    int* niz =(int*)calloc(N*2+1, sizeof(int));

    int totalBroken = 0;
    int targets[2*N+1];

    int temp;
    for (int i = 0; i < N; ++i) {
        scanf("%d", &temp);

        niz[temp+N]++;

        if (niz[temp+N] == K) {
            targets[totalBroken] = temp;
            totalBroken++;
        }
    }

    printf("%d", totalBroken);
    for (int i = 0; i < totalBroken; ++i) {
        printf(" %d", targets[i]);
    }

    free(niz);

    return 0;
}