using System;

namespace ConsoleApp1
{
    class Program

    {

        static void Main(string[] args)
        {
            int N, K, i, j, br = 0, k, temp;
            
            string[] s = new string[2];
            s = Console.ReadLine().Split(' ');
            N = Convert.ToInt32(s[0]);
            K = Convert.ToInt32(s[1]);
            int[] niz = new int[N];
            int[] ispisati = new int[N];
            s = new string[N];
            s = Console.ReadLine().Split(' ');

            for (i = 0; i < N; i++)
            {
                niz[i] = Convert.ToInt32(s[i]);
            }
            for (i = 0; i < N; i++)
            {
                temp = 1;
                for (j = i + 1; j < N; j++)
                {

                    if (niz[i] == niz[j])
                    {
                        temp++;
                        if (temp == K)
                        {
                            ispisati[br] = niz[i];
                            br++;
                            
                        }
                    }
                }
            }
             for(i=0;i<br;i++)
                 for (j = i+1; j < br; j++)
                 {
                     if (ispisati[i] == ispisati[j])
                     {
                         for (k = j; k < br - 1; k++)
                         {
                             ispisati[k] = ispisati[k + 1];

                         }
                         br--;
                     }
                 }
                 
            Console.WriteLine("{0}", br);
            for (i = 0; i < br; i++)
                Console.Write("{0} ", ispisati[i]);

            
        }
    }
}