#include<bits/stdc++.h>

using namespace std;

int A[2000010],NizR[2000010];

int N,K,a,Brojac;

int main()
{
    cin>>N>>K;

    for(int i=1; i<=N; i++)
    {
        cin>>a;

        a+=1000000;

        A[a]++;
        if(A[a]==K)
        {
            Brojac++;
            NizR[Brojac]=a-1000000;
        }
    }
    cout<<Brojac<<endl;
    for(int i =1; i<=Brojac; i++)cout<<NizR[i]<<" ";



    return 0;
}