import java.util.HashMap;
import java.util.Scanner;

public class Pikado {

	public static void main(String[] args) {
		Scanner ulaz = new Scanner(System.in);
		
		int n = ulaz.nextInt(), k = ulaz.nextInt();
		
		HashMap<Integer, Integer> mapa = new HashMap<>();
		
		int counter = 0;
		
		for (int i = 0 ; i < n; i++) {
			int polje = ulaz.nextInt();
			if (mapa.containsKey(polje)) {
				mapa.put(polje, mapa.get(polje)+1);
			} else {
				mapa.put(polje, 1);
			}
			
			if (mapa.get(polje) == k) {
				counter+=1;
			}
		}
		
		System.out.println(counter);
		for (int polje : mapa.keySet()) {
			if (mapa.get(polje) >= k) {
				System.out.print(polje + " ");
			}
		}
	}
	
}