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

#define NICE 69

int main(){
	int N, K; cin >> N >> K;
	set<int> s1;
	multiset<int> ms1;
	vector<int> v1;

	for(int i = 0; i < N; i++){
		int a; cin >> a;
		s1.insert(a);
		ms1.insert(a);
	}

	//clock_t tStart = clock();

	for(auto x : s1){
		if(ms1.count(x) >= K){
			v1.push_back(x);
		}
	}

	cout << v1.size() << "\n";
	for(auto x : v1)
		cout << x << " ";
	cout << "\n";

	//printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);

	return 0;
}