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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = Convert.ToInt32(s.Substring(0, s.IndexOf(" ")));
            int k= Convert.ToInt32(s.Substring(s.IndexOf(" ")+1));
            s = Console.ReadLine();
            int[] a = new int[n * 2 + 1];
            int x;
            int q = 0;
            string p=""; int br = 0;
            while (s.Length>0)
            {
                
                q = s.IndexOf(" ");
                if (q <0)
                {
                    x = Convert.ToInt32(s);
                    a[n + 1 + x]++;
                    if (a[n + 1 + x] == k)
                    {
                        p += x.ToString() + " ";
                        br++;
                    }
                    break;
                }
                x = Convert.ToInt32(s.Substring(0, q));
                s = s.Remove(0, q+1);
                a[n + 1 + x]++;
                if (a[n + 1 + x]==k)
                {
                    p += x.ToString() + " ";
                    br++;
                }
                
            }
            Console.WriteLine(br);
            Console.WriteLine(p);
            
        }
    }
}