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

namespace _1feladat
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string[] a2 = a.Split(' ');
            string[] b2 = b.Split(' ');
            List<string> list = new List<string>();

            Array.Sort(b2);

            int x = 1;
            int y = 0;
            for(int i = 0; i != b2.Length; i++)
            {
                if (i != b2.Length-1)
                {
                    if (b2[i] == b2[i + 1])
                    {
                        x++;
                    }
                    else
                    {
                        if (x >= Convert.ToInt32(a2[1]))
                        {
                            
                            list.Add(b2[i]);
                            y++;
                        }
                        x = 1;
                    }
                }
                else
                {
                    if (x >= Convert.ToInt32(a2[1]))
                    {
                       
                        list.Add(b2[i]);
                        y++;
                    }
                }
                
            }
            Console.WriteLine(y);
            foreach (var item in list)
            {
                Console.Write(item + " ");
            }

        }
    }
}