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

namespace prog
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            Dictionary<int, int> hit = new Dictionary<int, int>();
            HashSet<int> wearedOut = new HashSet<int>();
            
            input = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                int hitI = int.Parse(input[i]);
                if (!hit.ContainsKey(hitI))
                    hit[hitI] = 1;
                else
                    hit[hitI]++;
                if (hit[hitI] >= K && !wearedOut.Contains(hitI))
                    wearedOut.Add(hitI);
            }

            Console.WriteLine(wearedOut.Count);
            Console.WriteLine(wearedOut.ToList().Select(v => v.ToString()).Aggregate((a, b) => a + " " + b));
        }
    }
}