#include <iostream>
#include <map>
#include <set>

using namespace std;

int main() {
	set <int> x;
    map <int, int> b;
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) {
        if(b[a[i]]) b[a[i]]++;
        else b[a[i]] = 1;
        if(b[a[i]] == k) x.insert(a[i]);
	}
	cout << x.size() << endl;
	set <int>::iterator it;
	for(it = x.begin(); it != x.end(); it++)
		cout << *it << " ";
	return 0;	
}