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

namespace _A__PIKADO
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp1, inp2;
            Dictionary<int, int> hits = new Dictionary<int, int>() { };
            string[] inp1Array, inp2Array;
            int N, K;
            List<int> A;
            inp1 = Console.ReadLine();
            inp2 = Console.ReadLine();

            inp1Array = inp1.Split(' ');
            inp2Array = inp2.Split(' ');

            N = int.Parse(inp1Array[0]);
            K = int.Parse(inp1Array[1]);

            string outString = "";
            List<int> output = new List<int>();
            A = new List<int>();
            A.AddRange(Array.ConvertAll<string, int>(inp2Array, int.Parse));
            A.Sort();
            outString = "";
            foreach (int a in A)
            {
                outString = outString + a + " ";
            }
            int last = N+1;
            outString = "";

            for(int i = 0; i<A.Count; i++)
            {
                int n = A[i];
                int t = 0;
                if (hits.ContainsKey(n + N))
                {
                    t = ++hits[n + N];
                }
                else
                {
                    hits[n + N] = 1;
                    t = 1;
                }
                if (t >= K)
                {
                    if (!output.Contains(n))
                    {
                        outString = outString + n + " ";
                        output.Add(n);
                    }
                }
            }

            Console.WriteLine(output.Count);
            outString = "";
            foreach (int a in output)
            {
                outString = outString + a + " ";
            }
            Console.WriteLine(outString);


        }
    }
}