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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split ();
            int N = int.Parse(x[0]);
            int K = int.Parse(x[1]);
            var y = Console.ReadLine().Split();
            int i = 0;
            int i1 = 0;
            int [] t = new int[N+1];
            int [] r = new int[2*N];
            int z = 0;
            int z1 = 0;
            int z2 = 0;
            int z3 = 0;
            string q = "";
            while (i < N)
            {
                t[i] = int.Parse(y[i]);
                i++;
            }

            while (i1 < i)
            {
                i1 = z + 1;   
                        r[z1] = 0;
                        z3 = 0;
                        while ( i1<i )
                        {
                            if (t[z] == t[i1])
                            {
                                while (z3 < z)
                                {
                                    if (t[z3] != t[z])
                                    {
                                        r[z]++;
                                    }
                                    z3++;
                                }
                            }
                            z3 = 0;
                            i1++;
                            
                        }
                
                        if (r[z1] >= K-1)
                        {

                            while (z3 < z)
                            {
                                if (t[z3] == t[z])
                                {
                                    t[z] = 1000001;
                                }
                                z3++;
                            }
                            if (t[z] != 1000001)
                            {
                                z2++;
                                q += t[z] + " ";
                            }
                        }
                z1++;
                z++;
                i1 = z + 1;      
            }
            Console.WriteLine(z2);
            Console.WriteLine(q);
            Console.ReadKey();
        }
    }
}