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

namespace Petlja_A___Pikado
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] red = Console.ReadLine().Split(' ');
            long n = Convert.ToInt64(red[0]);
            long k = Convert.ToInt64(red[1]);

            red= Console.ReadLine().Split(' ');

            long[] mete = new long[n];

            for(long i=0;i<n;i++)
            {
                mete[i] = Convert.ToInt64(red[i]);
            }

            long br = 0;
            long brel = 0;
            long[] brojevi = new long[n];
            long[] brojacc = new long[n];
            bool[] status = new bool[n];
            for(long i=0;i<n;i++)
            {
                if(brel==0)
                {
                    brojevi[0] = mete[i];
                    brojacc[0] = 1;
                    brel++;
                    if (k == 1)
                    {
                        br++;
                    }
                }
                else
                {
                    bool mrk=false;
                    long j = 0;

                    while(mrk!=true && j<brel)
                    {
                        if(brojevi[j]==mete[i])
                        {
                            mrk = true;
                        }
                        else
                        {
                            j++;
                        }
                    }

                    if(mrk==true)
                    {
                        brojacc[j]++;
                        if (brojacc[j] >= k && status[j]==false)
                        {
                            br++;
                            status[j] = true;
                        }
                    }
                    else
                    {
                        brojevi[brel] = mete[i];
                        brojacc[brel] = 1;
                        brel++;
                    }


                }
            }

            Console.WriteLine(br);
            for(long i=0;i<brel;i++)
            {
                if (brojacc[i] >= k)
                {
                    Console.Write(brojevi[i] + " ");
                }
            }

            Console.ReadLine();
        } 
    }
}