#include <bits/stdc++.h>
using namespace std;
int n,k,x,br;
struct slog {
long long x;
bool y;

};
slog niz[100000009];
int main () {
    cin>>n>>k;

    for (int i=1;i<=n;i++){
        cin>>x;
        niz[x+n].x++;
            if (niz[x+n].x>=k){
              ///  cout<<"niz[x] "<<niz[x].x<<" "<<endl;
                niz[x+n].x-=k;
                niz[x+n].y=true;
                br++;

    ///            cout<<"1 or 0 "<<niz[x+n].y<<" "<<endl;
            }
    }
    cout<<br<<endl;
    for (int i=-n;i<=n;i++){
            if (niz[i+n].y==true){
            cout<<i<<endl;
        }
    }

return 0;
}