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