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

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0, k = 0;
            string s;
            s = Console.ReadLine();
            string[] words = s.Split(' ');
            foreach (var word in words)
            {
                n = int.Parse(words[0]);
                k = int.Parse(words[1]);
            }
            int[] niz = new int[n];
            int[] b = new int[n + n + 1];
            string s1;
            int q = 0;
            s1 = Console.ReadLine();
            string[] words1 = s1.Split(' ');
            foreach (var word in words1)
            {

                niz[q] = int.Parse(words1[q]);
                q++;
            }
            int br = 0;
          
            for (int j = 0; j < n; j++)
                {
                    b[niz[j] + n]++;
                }
            
            
            for (int i = 0; i < n+n+1; i++)
            {
                if (b[i] >= k) {  br++; }
            }
            
            Console.WriteLine(br);
            for (int i = 0; i < n+n+1; i++)
            {
                if (b[i] >= k) Console.Write(i-n+" ");
            }
            Console.WriteLine();
        }
    }
}