using System;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int[,] N = new int[n, 1];
            string[] s1 = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                N[i, 0] = int.Parse(s1[i]);
            }
            int[,] I2 = new int[n, 1];
            int x = 0;
            for (int j = 0; j < n; j++)
            {
                int br = 0;
                for (int i = j; i < n; i++)
                {
                    if (N[i, 0] == N[j, 0])
                    {
                        br++;
                    }
                }
                if (br >= k)
                {
                    I2[x, 0] = N[j, 0];
                    x++;
                }
            }
            Console.WriteLine(x);
            for (int i = 0; i <x; i++)
            {
                Console.Write(I2[i, 0] + " ");
            }

        }
    }
}