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(' ');
            int n = Convert.ToInt32(nk[0]);
            int k = Convert.ToInt32(nk[1]);
            string[] s = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(s[i]);
            int[] b = new int[n];
            int br = 1;
            int l=0;
            for (int i = 0; i < n; i++)
            {
                int 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 (int i = 0; i < l; i++)
               Console.Write(b[i]+" ");
            Console.ReadLine();

        }
    }
}