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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nk = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(nk[0]);
            long k = Convert.ToInt64(nk[1]);
            string[] s = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            for (long i = 0; i < n; i++)
                a[i] = Convert.ToInt64(s[i]);
            long[] b = new long[n];
            long br = 1;
            long l=0;
            for (long i = 0; i < n; i++)
            {
                long j=i+1;
                if (a[i] < n + 1)
                {
                    while (j < n )
                    {
                        if (a[i] == a[j])
                        {
                            br++;
                            a[j] = n + 1;
                        }
                        j++;
                    }
                    if (br >= k)
                    {
                        b[l] = a[i];
                        l++;
                    }
                }
                br = 1;
            }
            Console.WriteLine(l);
            for (long i = 0; i < l; i++)
               Console.Write(b[i]+" ");
            Console.ReadLine();

        }
    }
}