using System;

namespace Pikado
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, K, rossz = 0, i, j = 0, id, temp;

            //Kezdo adatok
            string[] values = Console.ReadLine().Split(' ');
            N = int.Parse(values[0]);
            K = int.Parse(values[1]);

            //Tombok letrehozasa
            int[] tablaPoz = new int[N + 1];
            int[] tablaNeg = new int[N];
            int[] tablaHPPoz = new int[N + 1];
            int[] tablaHPNeg = new int[N];
            int[] talalat = new int[N];
            int[] rosszMezo = new int[N];

            //Tabla letrehozasa
            for (i = 0; i <= N; i++) tablaPoz[i] = i;
            for (i = 0; i < N; i++) tablaNeg[i] = -(i + 1);

            //Tabla kiirasa
            /*for (i = N - 1; i >= 0; i--) Console.Write("{0} ", tablaNeg[i]);
            for (i = 0; i <= N; i++) Console.Write(" {0} ", tablaPoz[i]);
            Console.WriteLine();*/

            //Talalatok
            string[] value = Console.ReadLine().Split(' ');
            for (i = 0; i < N; i++)
            {
                talalat[i] = int.Parse(value[i]);
                temp = talalat[i];
                if (temp >= 0)
                {
                    tablaHPPoz[temp] = tablaHPPoz[temp] + 1;
                    if (tablaHPPoz[temp] >= K)
                    {
                        rossz++;
                        rosszMezo[j] = temp;
                        j++;
                        tablaHPPoz[temp] = -N;
                    }
                }
                else
                {
                    id = Math.Abs(temp) - 1;
                    tablaHPNeg[id] = tablaHPNeg[id] + 1;
                    if (tablaHPNeg[id] >= K)
                    {
                        rossz++;
                        rosszMezo[j] = temp;
                        j++;
                        tablaHPNeg[id] = -N;
                    }
                }
            }
            Console.WriteLine(rossz);
            for (i = 0; i < j; i++) Console.Write("{0} ", rosszMezo[i]);



            /*Console.WriteLine();
            Console.WriteLine("press any key");
            Console.ReadKey();*/

        }
    }
}