#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int pogodak[n],polja[2*n+1]={0},brpolja=0,zabrana[2*n+1]={0};
    for(int i=0;i<n;i++)
    {
        cin >> pogodak[i];
        polja[pogodak[i]+n]++;
        if(polja[pogodak[i]+n]>=k && zabrana[pogodak[i]+n]!=1)
        {
            brpolja++;
            zabrana[pogodak[i]+n]=1;
        }
    }
    cout << brpolja << endl;
    for(int i=0;i<2*n+1;i++)
    {
        if(polja[i]>=k) cout << i-n << " ";
    }

}