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