#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

//int niz[2000001], res[2000001];
int niz[100], res[100];
int main()
{
    int n, k, tmp, br = 0;

    scanf("%d%d", &n, &k);

    for(int i = 0; i < n * 2 + 1; i++)
    {
        niz[i] = 0;
        res[i] = 0;
    }

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

        if(niz[tmp + n] != -1)
            niz[tmp + n]++;

        if(niz[tmp + n] >= k)
        {
            niz[tmp + n] = -1;
            res[br] = tmp;
            br++;
        }
    }

    printf("%d\n", br);

    for(int i = 0; i < br; i++)
        printf("%d ", res[i]);

    return 0;
}