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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            long N = Convert.ToInt64(s[0]);
            long K = Convert.ToInt64(s[1]);
            string[] sl = Console.ReadLine().Split(' ');
            long br,brresult=0;
            string r=""; 
            bool x;
            for(int i = 0; i < N;i++)
            {
                br=0;
                x = true;
                for (int j = 0; j < N; j++)
                {
                    for (int p = 0; p <i;p++ )
                    {
                        if (sl[p] == sl[i]) x = false;
                        
                    }
                        if (sl[i] == sl[j]&&x)
                            br++;
                }
                    
                if(br>=K)
                {
                    brresult++;
                    r += " " + sl[i];
                }
            }
            Console.WriteLine(brresult.ToString());
            Console.WriteLine(r);
        }
    }
}