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

namespace zadatak_1
{
    class Program
    {
        static void Main(string[] args)
        {

            var ulazna_linija = Console.ReadLine().Split();
            Int64 n = int.Parse(ulazna_linija[0]);
            Int64 k = int.Parse(ulazna_linija[1]);
            Int64 c = 0;
            Int64 p = 0;
            Int64 l = 0;
            int[,] a = new int[n, n];
            int[,] b = new int[n, n];
            var ulazna_linij = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                a[0, i] = int.Parse(ulazna_linij[i]);


            for (Int64 m = -n; m < n; m++)
            {
                c = 0;
                for (int i = 0; i < n; i++)
                {
                    if (a[0, i] == m)
                        c++;
                    if (c == k)
                    {
                        b[0, l] = a[0, i];
                        c = 0;
                        l++;

                        break;

                    }
                }

            }



            Console.WriteLine(l);
            for (int i = 0; i < l; i++)
            {
                if (i != l - 1)
                {
                    Console.Write(b[0, i]);
                    Console.Write(" ");

                }
                else
                    Console.WriteLine(b[0, i]);
            }
        }
    }
}