#include <iostream>

using namespace std;

int main()
{
    long int n,i,k,u=0;
    cin >> n >> k;
    long int b[2*n+1],c[n/k],a[n];
    for (i=0;i<n;i++)
    {
        cin >> a[i];
        b[a[i]+n]=0;
    }
    for (i=0;i<n;i++)
    {
        b[a[i]+n]++;
        if (b[a[i]+n]==k)
        {
            c[u]=a[i];
            u++;
        }
    }
    cout << u << endl;
    for (i=0;i<u;i++)
        cout << c[i] << " ";
    return 0;
}