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

namespace Zadatak1Takmicenje
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine("unesi 2 br");

            string unosnk = Console.ReadLine();
            string[] final = unosnk.Split(' ');
            int n = int.Parse(final[0]);
            int k = int.Parse(final[1]);
            int np = 0;

            //Console.WriteLine("unesi pogodjena polja");

            string polja = Console.ReadLine();
            string[] pogodjena_polja = polja.Split(' ');
            int[] br_pogodjenih_polja = new int[n];
            for (int i = 0; i < n; i++)
            {
                br_pogodjenih_polja[i] = int.Parse(pogodjena_polja[i]);
            }

            int[] tabla = new int[2*n + 1];

            for (int i = 0; i < n; i++)
            {
                tabla[br_pogodjenih_polja[i] + n]++; 
            }

            //foreach (int num in tabla)
            //{
            //    Console.Write(num + " ");
            //}
            //Console.WriteLine();

            for (int i = 0; i < tabla.Length; i++)
            {
                if (tabla[i] >= k)
                {
                    np++;
                }
            }

            Console.WriteLine(np);

            for (int i = 0; i < tabla.Length; i++)
            {
                if (tabla[i] >= k)
                {
                    Console.Write(i - n + " ");
                }
            }

            Console.ReadKey();

        }
    }
}