#include <iostream>

using namespace std;

int main()
{
    int n, k, br=0;
    cin>>n>>k;
    int a[n+5],b[2*n+5];
    for(int i=0;i<=2*n;i++)b[i]=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]+=n;
        b[a[i]]++;
        if(b[a[i]]==k)br++;
    }
    cout<<br<<endl;
    for(int i=0;i<=2*n;i++)
    {
        if(b[i]>=k)cout<<i-n<<" ";
    }
}