#include <iostream>
#include <set>
#define N_MAX 1000000

using namespace std;

int A[N_MAX],br[N_MAX];
int N, K, brPremestanja=0;
set<int> s;
set<int>::iterator it;
pair<set<int>::iterator, bool> par;
int main() {
	int pom;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> N >> K;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		par = s.insert(A[i]);
		if (par.second == true) br[A[i]] = 1;
		else 
		{
			br[A[i]]++; 
		}
	}
	for (it = s.begin();it != s.end();it++) {
		if (br[*it] >= K) brPremestanja++;
	}
	cout << brPremestanja << "\n";
	for (it = s.begin();it != s.end();it++) {
		if (br[*it] >= K) {
			pom = *it;
			cout << pom << " "; 
		}
	}
}