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

namespace ConsoleApplication30
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k, x, b = 0;
            string[] s;
            s = Console.ReadLine().Split();
            n = int.Parse(s[0]);
            k = int.Parse(s[1]);
            int[] niz = new int[2001];
            s = Console.ReadLine().Split();
            for (int i = 0; i < 2001; i++)
            {
                niz[i] = 0;
            }
            for (int i = 0; i < n; i++)
            {
                x = int.Parse(s[i]);
                niz[x + 1000]++;
            }
            for (int i = 0; i < 2001; i++)
            {
                if (niz[i] >= k)
                    b++;
            }
            Console.WriteLine(b);
            for (int i = 0; i < 2001; i++)
            {
                if (niz[i] >= k)
                    Console.Write(i - 1000 + " ");
            }
        }
    }
}