#include <iostream>
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N, K;
	cin >> N >> K;
	//int* a = new int[2000005];//2*N+5
	//for(int i = 0; i < 2000005; i++){
	//	a[i] = 0;
	//}
	vector<int> a(2000005, 0);
	vector<int> v;
	int temp = 0, count = 0;
	for(int i = 1; i <= N; i++){
		cin >> temp;
		a[N+temp]++;
		if(a[N+temp] == K){
			count++;
			v.push_back(temp);
		}
	}
	//delete [] a;
	cout << count << endl;
	for(int i : v){
		cout << i << " ";
	}
	return 0;
}