#include <bits/stdc++.h>

using namespace std;
const int N = 1e6;
int fields[N*2+1] = {};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k, a, result = 0;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> a;
        fields[n+a]++;
        if(fields[n+a]==k) result++;
    }
    cout << result << endl;
    for(int i=0;i<=2*n;i++)
    {
        if(fields[i] >= k) cout << i-n << " ";
    }
    return cout << endl, 0;
}