import java.util.*;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Zadatak1 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        Integer[] array = new Integer[scanner.nextInt()];
        int max = scanner.nextInt();

        IntStream.range(0, array.length).forEach(i -> array[i] = scanner.nextInt());

        List<Integer> intList = Arrays.asList(array);
        Set<Integer> intSet = new HashSet<>(intList).stream().filter(i -> Collections.frequency(intList, i) >= max).collect(Collectors.toSet());

        System.out.println(intSet.size());
        for (int i : intSet)
            System.out.print(i + " ");
        System.out.println();



    }
}