#include <iostream>
#include <cstdio>

using namespace std;
long x[2000003];
int main()
{
    long n, k, pom, suma = 0;
    scanf("%ld %ld",&n, &k);
    for (long i = 0; i < n; i ++)
    {
        scanf("%ld", &pom);
        x[pom + n] ++;
        if(x[pom + n] >= k)
        {
            suma ++;
            x[pom + n] = - n - 1;
        }
    }
    printf("%ld\n", suma);
    for (long i = 0; i < 2 * n; i ++)
    {
        if(x[i] < 0)
            printf("%ld ", i - n);
    }
    return 0;
}