using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace petlja2
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] unos1, unos2;
			unos1 = Console.ReadLine().Split(' ');
			int n = Convert.ToInt32(unos1[0]);
			int k = int.Parse(unos1[1]);
			List<int> pogodjenaPolja = new List<int>();
			unos2 = Console.ReadLine().Split(' ');
			for (int i = 0; i < n; i++)
			{
				pogodjenaPolja.Add(Convert.ToInt32(unos2[i]));
			}
			Dictionary<int, int> ponavljanja = pogodjenaPolja.GroupBy(x => x).Where(g => g.Count() >= k).ToDictionary(x => x.Key, y => y.Count());
			Console.WriteLine(ponavljanja.Count);
			foreach (var element in ponavljanja)
			{
				if (element.Value >= k)
				{
					Console.Write(element.Key + " ");
				}
			}
		}
	}
}