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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] red = Console.ReadLine().Split();
            int n = int.Parse(red[0]);
            int k = int.Parse(red[1]);

            red = Console.ReadLine().Split();
            int[] br = new int[2*n+1];
            int p = 0;
            List<string> stek = new List<string>();

            for(int i=0;i<n;i++)
            {
                int sos = int.Parse(red[i]) + n;
                br[sos]++;
                if(br[sos]==k)
                {
                    stek.Add(red[i]);
                    p++;
                    br[sos]++;
                }
            }
            Console.WriteLine(p);
            foreach (object x in stek)
                Console.Write(x + " ");
        }
    }
}