#include <bits/stdc++.h>
int main()
{
	int n, k;
	scanf("%d", &n);
	scanf("%d", &k);
	int* polja = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &polja[i]);
	int* niz1 = new int[n];
	int* niz2 = new int[n];
	int v = 0, p = 0, r = 0, t;
	for (int i = 0; i < n; i++)
	{
		r = 0;
		for (int j = 0; j < v; j++)
			if (polja[i] == niz1[j])
				r = 1;
		if (r == 0)
		{
			t = 1;
			for (int j = i + 1; j < n; j++)
				if (polja[i] == polja[j])
					t++;
			if (t >= k)
				niz2[p++] = polja[i];
			niz1[v++] = polja[i];
		}
	}
	printf("%d\n", p);
	for (int i = 0; i < p; i++)
		printf("%d ", niz2[i]);
	return 0;
}