#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, k;
vector<int> niz;
map<int, int> mapa;
int main() {
    IOS;
    cin >> n >> k;
    for(int i=0; i<n; ++i) {
        int br; cin >> br;
        mapa[br]++; if(mapa[br]==k) niz.push_back(br);
    }
    cout << niz.size() << endl;
    for(auto x:niz) cout << x << ' ';
    return 0;
}