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

namespace Takmicenje
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] podela = Console.ReadLine().Split();
            int N = int.Parse(podela[0]);
            int K = int.Parse(podela[1]);
            string[] pogodak = Console.ReadLine().Split();

            int[] polja = null;
            polja = new int[N];

            int i = 0;
            foreach (string a in pogodak)
            { polja[i] = int.Parse(a); i++; }

            var dict = new Dictionary<int, int>();

            foreach (var value in polja)
            {
                if (dict.ContainsKey(value))
                    dict[value]++;
                else
                    dict[value] = 1;
            }

            i = 0;

            foreach (var pair in dict)
                if (pair.Value >= K)
                    i++;
            
            Console.WriteLine(i);

            foreach (var pair in dict)
                if (pair.Value >= K)
                    Console.Write(pair.Key + " ");
            
            Console.ReadLine();
        }
    }
}