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

namespace ConsoleApplication1
{
    class Program
    {
        static void provera(int[] b, ref int zbir, int t, ref int r)
        {
            bool p = true;
            for (int i = 0; i < r; i++)
            {
                if (b[i] == t)
                    p = false;
            }
            if (p == true)
            {
                zbir++;
                b[r] = t;
                r++;
            }
        }
        static void Main(string[] args)
        {
            int br = 0, zbir = 0, r = 0;
            string[] p = Console.ReadLine().Split();
            int n = Convert.ToInt32(p[0]);
            int k = Convert.ToInt32(p[1]);
            int[] a = new int[n];
            int[] b = new int[n];
            string[] g = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
                a[i] = Convert.ToInt32(g[i]); 
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (a[i] == a[j])
                    {
                        br++;
                    }
                    if (br == k)
                    {
                        provera(b, ref zbir, a[i], ref r);
                    }
                }
                br = 0;
            }
            Console.WriteLine(zbir);
            for (int i = 0; i < r; i++)
                Console.Write(b[i] + " ");
        }
    }
}