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

namespace takmicenje2._1
{
    class Program
    {
        static int ponav(int[] a,int n,int k)
        {

            int br = 0;
            for (int i = 0; i < n; i++)
            {             
                int j;

                for (j = 0; j < n; j++)
                    if (i != j && a[j] == a[i])
                        break;
                if (j == n)
                    br++;

                if (br == k)
                    return a[i];
            }

            return -1;
        }

        static void Main(string[] args)
        {
           
            string readLine1 = Console.ReadLine();
            string[] stringArray1 = readLine1.Split(' ');
            long N = int.Parse( stringArray1[0]);
            long K =int.Parse( stringArray1[1]);
            int[] A = new int[N];
            int[] s=new int [100];
            int br = 0,count2;
            int br1 = 0;
            int[] kon=new int[100];
            int m = 0;
            int l = 0;
            string readLine = Console.ReadLine();
            string[] stringArray = readLine.Split(' ');
         
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse(stringArray[i]); 
            for(int i=0;i<N-1;i++)
            {
                br = A[i];
                count2 = 0;
                for(int j=0;j<N;j++)
                {
                    if(br==A[j])
                    {
                        count2++;
                    }
                    if(count2==K)
                    {
                        br1++;
                        s[l] = A[j];
                        l++;
                        break;
                    }
                }
            }
            Console.WriteLine((br1+1)/K);
            for(int i=0;i<(br1+1)/K;i++)
            {
                kon[m] = ponav(s, l, i);
                m++;
            }
             for(int i=0;i<m;i++)
            {          
                Console.Write(kon[m] + " ");           
            }
            Console.ReadLine();

        }
    }
}