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[] s = Console.ReadLine().Split();
            uint n = uint.Parse(s[0]);
            uint k = uint.Parse(s[1]);
            uint[] a = new uint[n];
            string[] s1 = Console.ReadLine().Split();
            for (uint i = 0; i < n; i++)
            {
                a[i] = uint.Parse(s1[i]);
            }
            Array.Sort(a);
            uint x = 0;
            string y = "";
            for (uint i = 1; i < n - 1; i++) 
            {
                if ((a[i] == a[i - 1] && a[i] != a[i + 1])||(i == n - 2 && a[i] != a[i - 1] && a[i] == a[i + 1]))
                {
                    x++;
                    y += a[i] + " ";
                }
            }
            Console.WriteLine(x);
            Console.WriteLine(y);
        }
    }
}