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

namespace pikado
{
    class Program
    {
        static void Main(string[] args)
        {
            var ul = Console.ReadLine().Split();
            Int64 n = Int64.Parse(ul[0]);
            Int64 k = Int64.Parse(ul[1]);
            int i, j;
            Int64[] a = new Int64 [n];
            var ul1 = Console.ReadLine().Split();
            for(i=0;i<n;i++)
            {
                a[i] = Int64.Parse(ul1[i]);
            }
            Int64 br = 1, l = 0, br2 = 0;
            Int64[] b = new Int64[n];
            for (i = 0; i < n; i++)
            {
                br = 1;
                for (j = i+1; j < n; j++)
                {
                    if(a[i]==a[j] && a[i]<=n)
                    {
                        a[j] = n + 1;
                        br++;
                    }
                }
                if(br/k>0)
                {
                    b[l] = a[i];
                    l++;
                    br2++;
                }
            }
            Console.WriteLine(br2);
            for (i = 0; i < br2; i++)
            {
                Console.Write(b[i] + " ");
            }
            Console.WriteLine();
        }
    }
}