#include <bits/stdc++.h>
using namespace std;

#define kraj return 0;

int main()
{
    int n,k,x,br=0;
    cin>>n>>k;
    vector<int> a(2*n+1,0);
    vector<int> ans;
    for(int i=0; i<n; ++i) {
        cin>>x;
        if(x>=0) a[x]++;
        else a[n-x]++;
    }
    for(int i=0; i<=n*2; ++i) {
        if(a[i]>=k) {
            br++;
            if(i<=n) ans.push_back(i);
            else ans.push_back(n-i);
        }
    }
    cout<<br<<endl;
    for(int i=0; i<br; ++i) {
        cout<<ans[i]<<" ";
    }
    kraj
}