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