#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

	int n, k, a, m, c, b=0;
	int d[10000000];

int main(){
	ios_base::sync_with_stdio(false);
	
	list <int> l1;
	list <int> l2;
	
	
	
	cin >> n >> k;
	
	for(int i = 0; i < n; i++){
		cin >> a;
		d[i] = a;
		l1.push_back(a);
		l2.push_back(a);
	}
	
	l1.sort();
	l1.unique();
	
	l2.sort();
	l2.unique();
	
	m = l1.size();
	
	for(int i = 0; i<m; i++){
		c = l1.front();
		if(count(d, d+n, c) >= k) b++;
		l1.pop_front();
	}
	
	cout << b << endl;
	
	for(int i = 0; i < m; i++){
		c = l2.front();
		if(count(d, d+n, c) >= k) cout << c << " ";
		l2.pop_front();	
	}
	
	
	
	
	return 0;
}