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

namespace Pikado
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int N = int.Parse(str[0]);
            int K = int.Parse(str[1]);
            int br = 0;
            int br1 = 1;
            int[] a = new int[N];
            str = Console.ReadLine().Split();
            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(str[i]);
            }
            Array.Sort(a);
            string s = "";
            for (int i = 0; i < N - 1; i++)
            {
                if (a[i] == a[i + 1]) br1++;
                else br1 = 1;
                if (br1 == K)
                {
                    s += a[i]+" ";
                    br++;
                }
            }
            Console.WriteLine(br);
            Console.WriteLine(s);
        }
    }
}