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

namespace ConsoleApplication14
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[1000000];
            int[] br = new int[1000000];
            int[] b = new int[1000000];
            bool[] x = new bool[1000000];


            string[] str = Console.ReadLine().Split();

            int n = Convert.ToInt32(str[0]);
            int k = Convert.ToInt32(str[1]);

             str = Console.ReadLine().Split();

            for (int i = 0; i < n; i++)
            {
                a[i] =Convert.ToInt32( str[i]);
                x[i] = false;
            }

            

            int br2 = 0;
            

            for (int i = 0; i < n; i++)
            {
                br[i] = 0;
                if (!x[i])
                {


                    for (int j = i; j < n; j++)
                    {
                        if (a[i] == a[j])
                        {
                            br[i]++;
                            x[j] = true;
                        }
                    }
                }
                if (br[i]>=k)
                {
                    b[br2] = a[i];
                    br2++;
                    
                }
            }
            
            Console.WriteLine(Convert.ToString(br2));

            for (int i = 0; i < br2; i++)
            {
                if (i!=br2-1) 
                {
                    Console.Write(Convert.ToString(b[i]) + " ");
                }
                else
                {
                    Console.Write(Convert.ToString(b[i]));
                }
               
            }

           
        }

       

      
    }
}