#include <iostream>

using namespace std;

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