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

namespace ConsoleApplication2
{
    class Program
    {
        private static int j;

        static void Main()
        {
            var ulaz = Console.ReadLine().Split();
            int n = int.Parse(ulaz[0]);
            int k = int.Parse(ulaz[1]);
            int br = 0, l = 0;
            int[] b = new int[100];
            int[] a = new int[100];
            var ulaz2 = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(ulaz2[i]);
            }
            for (int i = -n; i <= n; i++)
            {
                br = 0;
                for (int j = 0; j < n; j++)
                {
                    if (a[j] == i)
                    {
                        br++;
                        if (br >= k)
                        {

                            b[l] = a[j];
                            l++;
                            j = n;
                        }
                    }
                }
            }
            Console.WriteLine(l);
            for (int i = 0; i < l; i++)
            {
                Console.Write(b[i] + " ");
            }
            Console.WriteLine(" ");
        }
    }
}