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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = new string[2];
            str = Console.ReadLine().Split();
            int n = Convert.ToInt32(str[0]);
            int k = Convert.ToInt32(str[1]);
            string[] niz = new string[n * 2];
            niz = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(niz[i]);
            int br = 0;
            int provera=1;
            int[] rez=new int[n/2];
            int jeli = 0;
            for (int i = 0; i < n; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    if (a[i] == a[j])
                    {
                        provera++;
                        if (provera == k)
                        {
                            for (int l = 0; l < rez.Length; l++)
                            {
                                if (a[i] != rez[l]) jeli++;
                                if (jeli == rez.Length)
                                {
                                    br++;
                                    rez[br - 1] = a[i];
                                }
                            }
                            
                        }
                    }
                }
            }
            Console.WriteLine(br);
            for (int i = 0; i < br; i++)
            {
                Console.Write(rez[i] + " ");
            }
            Console.ReadKey();
        }
            


        }
    }