#include<bits/stdc++.h>

using namespace std;

int n,br,k,x,a[1000009],b[2000009],brojac[2000009],pogodci[2000009];

int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
    cin>>a[i];
    for(int m=-n;m<=n;m++){
        b[m]=m;
        if(a[i]==b[m])brojac[m]++;
        if(brojac[m]>=k)pogodci[m]=m;
        if(a[i]==pogodci[m])pogodci[m]=m;
    }
    if(a[i]==0)br++;
}
if(br==0){
    for(int r=-n;r<=n;r++){
        if(brojac[r]>=k)x++;
    }
    cout<<x<<endl; 
    for(int r=-n;r<=n;r++){
        if(pogodci[r]!=0)    
        cout<<pogodci[r]<<" ";  
    }
}

return 0;
}