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

int f[3000006];

signed main() {

    int n, k;
    cin >> n >> k;

    for (int i = 1; i <= n; i++) {
        int x; cin >> x;
        f[x+n]++;
    }

    vector<int> ans;
    for (int i = 0; i <= n+n; i++) {
        if (f[i] >= k)
            ans.push_back(i-n);
    }

    cout << ans.size() << '\n';
    for (auto x : ans)
        cout << x << ' ';
}