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

namespace TakProg_1
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<int, int> tabla = new Dictionary<int, int>();
            string[] s = Console.ReadLine().Split();
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            s = Console.ReadLine().Split();
            List<int> zaIspis = new List<int>();
            for (int i = 0; i < N; i++)
            {
                int pogodjen = int.Parse(s[i]);
                if (!tabla.ContainsKey(pogodjen))
                {
                    tabla.Add(pogodjen, 1);
                }
                else
                {
                    tabla[pogodjen]++;
                }
                if (tabla[pogodjen] == K)
                {
                    zaIspis.Add(pogodjen);
                }
            }
            Console.WriteLine(zaIspis.Count);
            foreach (int ispis in zaIspis)
                Console.Write(ispis + " ");
        }
    }
}