#include <iostream>
#define  MAX 2000001
using namespace std;
int polje[MAX],zameni[MAX];
int main() {
    int n, k;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int br=0,p;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin>>p;
        p=p+n;
        polje[p]++;
        if(polje[p]==k)
        {
            zameni[br]=p-n;
            br++;
        }
    }
    cout<<br;
    for(int i=0;i<br;i++)
    {
        if(i==0)cout<<endl;
        cout<<zameni[i]<<" ";
    }
    return 0;
}