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

#define pb push_back

int n, k;
int cnt[2000005];
vector<int> res;
int resSize;

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

    cin >> n >> k;

    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;

        if(++cnt[x + 1000000] == k){
            res.pb(x);
            ++resSize;
        }
    }

    cout << resSize << "\n";
    for(auto x : res){
        cout << x << " ";
    }
    cout << "\n";

    return 0;
}