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

namespace ConsoleApplication1
{
    class Program
    {
        
        static void Main(string[] args)
        {

            
            int s = 0;
            int i = 0;
            string x = Console.ReadLine();
            string[] Z = x.Split(' ');  // deljenje na N i K.

            int N = int.Parse(Z[0]);
            int K = int.Parse(Z[1]);
            int[] c = new  int[N];
            int[] niz = new int[N];
            string y = Console.ReadLine();
            string[] polja = y.Split(' ');
            
            for (i = 0; i < N; i++)
            {
                c[i] = 1;
                for (int j = 1; j < N; j++)
                {
                    if (polja[i] == polja[j])
                    {                        
                        c[i]++;
                        s++;
 
                    }
                }
            }

            var list = new List<int>();
            for (int w = 0; w < N; w++)
            {
                if (c[w] > K)
                {
                    niz[w] = int.Parse(polja[w]);
                    
                }
                
             }
            var array = list.ToArray();
            array = niz.Distinct().ToArray();

            var arr = array.Skip(1).ToArray();
            int p = arr.Length;

          
            Console.WriteLine(p);
            
            for (int u = 0; u < p; u++)
            {
                Console.Write(arr[u]);
                Console.Write(" ");
            }

                Console.ReadLine();
            
        }
    }
}