#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n, k, cnt = 0, ans = 0;
	cin >> n >> k;
	vector<int> v(n), a(n,0), c;
	for(auto &i : v)	cin >> i;
	for(int i = 0; i < n; i++)
	{
		if(a[i] != 1){
			a[i] = 1, cnt = 1;
			for(int j = 0; j < n; j++)
				if(v[i] == v[j] and i != j)	cnt++, a[j] = 1;
			if(k <= cnt) ans++, c.push_back(v[i]);
		}
	}
	cout << ans << "\n";
	for(auto &i:c) cout << i << " ";
	return 0;
}