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

namespace ConsoleApp20
{
    class Program
    {
        
        static int brojac(int[]niz,int i,int n)
        {
            int c = 0;
            for (int j = 0; j < n; j++)
                if (niz[i] == niz[j]) c++;
            return c;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Unesi N i K");
            //prom
            int n = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            int[] niz = new int[n];
            int[] br = new int[n];
            int c = 0;
            //kod
            Console.WriteLine();
            for (int i = 0; i < n; i++)
               niz[i] = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
                br[i] = 1;
            for (int i = 0; i < n - 1; i++)
                for (int j = i + 1; j < n; j++)
                    if (niz[i] == niz[j])
                    {
                        niz[j] = niz[n - 1];
                        n--;
                        br[i] += 1;
                        j--;
                    }
            for (int i = 0; i < n; i++)
                if (br[i] >= k) c++;
            Console.WriteLine(c);
            for (int i = 0; i < n; i++)
                 if(br[i]>=k) Console.Write(niz[i]+ " ");
            Console.ReadLine();
        }
    }
}