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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string firstLine = Console.ReadLine();
            int n = int.Parse(firstLine.Split(' ')[0]);
            int k = int.Parse(firstLine.Split(' ')[1]);
            string[] a = Console.ReadLine().Split(' ');
            string[] set = new HashSet<string>(a).ToArray();
            int count;
            int brojPolja = 0;
            int[] oznake = new int[n];
            for (int i = 0; i < set.Length; i++)
            {
                count = 0;
                for (int j = 0; j < a.Length; j++)
                {
                    if(set[i] == a[j])
                    {
                        count++;
                    }
                }
                if(count >= k)
                {
                    oznake[brojPolja] = int.Parse(set[i]);
                    brojPolja++;
                }
            }
            Console.WriteLine(brojPolja);
            for (int i = 0; i < brojPolja; i++)
            {
                Console.Write(oznake[i]);
                if (i <= brojPolja - 2)
                    Console.Write(' ');
            }
        }
    }
}