#include <stdio.h>
int o = 0;
int provera(int n,int *br,int a,int t)
{
	int i,j = 0;
	for(i = 0; i < n; i++)
	{
		if(a == br[i]) j++;
	}
	if(j >= t)
	{
		o++;
		return 1;
	}
	return 0;
}
int razmena(int *a, int *b)
{
	int pom;
	pom = *a;
	*a = *b;
	*b = pom;
}
int sort(int n, int *br)
{
	int i,j;
	for(i = 0; i < n; i++)
	{
		for(j = i; j < n; j++)
		{
			if(br[i] > br[j]) razmena(&br[i],&br[j]);
		}
	}
}
main()
{
	int n,t,i,j,k,brj = 0;
	scanf("%d",&n);
	int u[n],p[n];
	scanf("%d",&t);
	for(i = 0; i < n; i++)
	{
		scanf("%d",&u[i]);
	}
	sort(n,u);
	for(j = 0; j < n; j++)
	{
		if(u[j] != u[j+1])
		{
			if(provera(n,u,u[j],t))
			{
				p[brj] = u[j];
				brj++;
			}
		}
	}
	printf("%d\n",o);
	for(k = 0; k < o; k++)
	{
		printf("%d ",p[k]);	
	}
}