#include<bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

const int N = 1e6;
const int delta = 1e6;

int cnt[2*N + 10];
vector<int> res;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x + delta]++;
    }
    for(int i = -n; i <= n; i++)
        if(cnt[i + delta] >= k)
            res.pb(i);
    cout << res.size() << "\n";
    for(int i = 0; i < res.size(); i++)
        cout << res[i] << " ";


    return 0;
}