#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n, k, x, t;
	x = 1;
	t = 0;
	cin >> n >> k;
	vector <int> gale(n);
	vector <int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (a[i] == a[j])
			{
				x++;
			}
		}
		if (x >= k)
		{
			gale[t] = a[i];
			t++;
		}
		x = 1;
	}
	cout << t << endl;
	for (int i = 0; i < t; i++) cout << gale[i] << ' ';
	return 0;
}