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

namespace takmicenje2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            string a = Console.ReadLine();

            string[] pocetni = a.Split(' ');

            int K = int.Parse(pocetni[1]);

            a = Console.ReadLine();
            pocetni = a.Split(' ');
            int[] myInts = Array.ConvertAll(pocetni, int.Parse);

            a = string.Empty;
            Dictionary<int, int> dict = new Dictionary<int, int>();
            foreach (var item in myInts)
            {
                if (dict.ContainsKey(item)) dict[item]++;
                else dict[item] = 1;
            }
            foreach (var item in dict)
            {
                if ((item.Value) / K > 0)
                {
                    a += (item.Key).ToString() + " ";
                    n++;
                }
            }
            Console.WriteLine(n);
            Console.WriteLine(a);
        }
    }
}