using System;
class Program
{
    static void Main(string[] args)
    {
        string[] c = Console.ReadLine().Split(' ');
        int N = int.Parse(c[0]), K = int.Parse(c[1]);
        c = Console.ReadLine().Split(' ');
        int[] a = new int[2*N + 1], br = new int[2*N + 1];
        for (int i = 0; i < 2 * N + 1; i++)
        {
            a[i] = 0;
            br[i] = N + 1;
        }
        for (int i = 0; i < N; i++)
        {
            a[int.Parse(c[i]) + N] += 1;
        }
        bool morthank = true;
        int brojac = 0;
        while (morthank)
        {
            morthank = false;
            for (int i = 0; i < 2 * N + 1; i++)
            {
                if (a[i] >= K)
                {
                    morthank = true;
                    a[i] -= K;
                    br[brojac] = (i - N);
                    brojac++;
                }
            }
        }
        Console.WriteLine(brojac);
        for(int i = 0; i < 2 * N + 1; i++)
        {
            if(br[i]!=N+1)Console.Write(br[i] + " ");
        }
    }
}