using System;
using System.Collections.Generic;

public class Isplata
{
	public static void Main()
	{
		int n , k , z=0;
		int[] a , b;
		int[] order = Translate();
		n = order[0];
		k = order[1];
		a = Translate();
		b = new int[2*n+1];
		List<int> List = new List<int>();
		for(int i=0; i<n; i++)
		{
			b[a[i]+n]++;
			if(b[a[i]+n]==k)
			{
				z++;
				List.Add(a[i]);
			}
		}
		Console.WriteLine(z);
		foreach(int o in List)
		{
			Console.Write(o + " ");
		}
	}

	public static int[] Translate()
	{
		return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), int.Parse);
	}
}