using System;

namespace Pikado
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string[] s2 = s1.Split(' ');
            int N = Convert.ToInt32(s2[0]);
            int K = Convert.ToInt32(s2[1]);
            s1 = Console.ReadLine();
            string[] s3 = s1.Split(' ');
            int[] pikado = new int[2 * N + 1];
            int br = 0;
            string zamene = "";
            for(int i = 0; i < N; i++)
            {
                pikado[N + Convert.ToInt32(s3[i])]++;
                if(pikado[N + Convert.ToInt32(s3[i])] == K)
                {
                    br++;
                    zamene += s3[i];
                    zamene += " ";
                }
            }
            Console.WriteLine(br);
            Console.WriteLine(zamene);
            Console.ReadLine();
        }
    }
}