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)
        {
            var ulaz1 = Console.ReadLine().Split();
            long n = long.Parse(ulaz1[0]);
            long k = long.Parse(ulaz1[1]);
            long[] a = new long[n];
            long[] pp = new long[n];
            long i, j, br;
            long uk = 0;
            var ulazniz = Console.ReadLine().Split();
            for(i = 0; i < a.Length; i++)
            {
                a[i] = long.Parse(ulazniz[i]);
                pp[i] = -1;
            }          
            for(i = 0; i < a.Length; i++)
            {
                br = 1;
                for(j = i + 1; j < a.Length; j++)
                {
                    if(a[i] == a[j])
                    {
                        br++;
                        pp[j] = 0;
                    }
                }
                if(pp[i] != 0)
                {
                    pp[i] = br;
                }              
            }  
            for(i = 0; i < a.Length; i++)
                {
                    if(pp[i] > 1)
                    {
                       uk++;
                    }                  
                }
            Console.WriteLine(uk);
            for (i = 0; i < a.Length; i++)
            {
                if (pp[i] > 1)
                {               
                    Console.Write(a[i] + " ");
                }
            }
        }
    }
}