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

namespace ConsoleApp20
{
    class Program
    {
        static void br2(int[] niz, int n, int[] br, out double[] res,int k, out int c)
        {
            res = new double[n];
            c=0;
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = i + 1; j < n; j++)
                    if (br[i] == br[j] && br[i]>=k)
                        if (niz[i] == niz[j])
                        {
                            if (niz[i] == 0)
                            {
                                res[c] = -0.5;
                                br[j] = 0;
                                c++;
                            }
                            else
                            {
                                br[j] = 0;
                                res[c] = niz[i];
                                c++;
                            }
                        }
            }
        }
        static int brojac(int[]niz,int i,int n)
        {
            int c = 0;
            for (int j = 0; j < n; j++)
                if (niz[i] == niz[j]) c++;
            return c;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Unesi N i K");
            //prom
            int n = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            int[] niz = new int[n];
            int[] br = new int[n];
            double[] res;
            int c;
            //kod
            Console.WriteLine();
            for (int i = 0; i < n; i++)
               niz[i] = int.Parse(Console.ReadLine()); 
            for(int i=0;i<n;i++)
                br[i] = brojac(niz, i, n);
            br2(niz, n, br, out res, k,out c);
            // izlaz
            Console.WriteLine("Resenja: ");
            for (int i = 0; i < n ; i++)
                for (int j = 0; j < n; j++)
                    if (res[i] == res[j])
                    {
                        res[j] = res[n - 1];
                        n--;
                    }
            c = 0;
            for (int i = 0; i < n; i++)
            {
                if (res[i] == -0.5) c++;
                else if (res[i] != 0) c++;
            }
            Console.WriteLine(c);
            for(int i=0;i<n;i++)
            {
                if (res[i] == -0.5) Console.Write(0+ " ");
                else if (res[i] != 0) Console.Write(res[i]+" ");
            }
            Console.ReadLine();
        }
    }
}