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

namespace Takmicenje_Pikado
{
    
    class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            string[] tokens = Console.ReadLine().Split();
            n = int.Parse(tokens[0]);
            k = int.Parse(tokens[1]);
            int[,] m = new int[2,n+1];
            int[] a = new int[n+1];
            int br = 0;
            int r = 0;
            string s="";
            bool t = true;
            tokens = Console.ReadLine().Split();
            for(int i=0; i < n; i++)
            {
                a[i] = int.Parse(tokens[i]);
            }
            for (int i = 0; i < n; i++)
            {
               for(int j=0; j < br; j++)
                {
                    if (a[i] == m[0, j])
                    {
                        t = false;
                        m[1, j]+=1;
                        break;
                    }
                }
                if (t)
                {
                    m[0,br] = a[i];
                    m[1, br] += 1;
                    br++;
                }
                t = true;
            }
            for(int i = 0; i < br; i++)
            {
                if(m[1,i] >= k)
                {
                    r++;
                    s +=(Convert.ToString(m[0, i]))+" ";
                }
            }
            Console.WriteLine("{0} \n",r);
            Console.WriteLine(s);
        }
    }
}