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

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

	long long n, k, x;
	cin >> n >> k;
	long long targets[2*n] = {};
	vector<long long> to_be_replaced;

	for(long long i = 0; i < n; i++){
		cin >> x;
		targets[x+n]++;
		if(targets[x+n] == k) to_be_replaced.push_back(x);
	}

	cout << to_be_replaced.size() << "\n";
	for(long long i = 0; i < to_be_replaced.size(); i++){
		cout << to_be_replaced[i] << " ";
	}

	return 0;
}