import java.util.Scanner;

/**
 *
 * @author Nemanja
 */
public class Pikado1 {

    public static void main(String[] args) {
        final int MAX_BR_POGODAKA = 1000000;
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int K = input.nextInt();

        int[][] A = new int[MAX_BR_POGODAKA][2];

        int brojPoljaZaZameniti = 0;
        for (int i = 0; i <= (N * 2); i++) {
            A[i][0] = -N + i;
            A[i][1] = 0;
        }
        /* for (int i = 0; i <= (N * 2); i++) {
            System.out.print(A[i][0] + " ");
        }*/
        for (int i = 0; i <= N - 1; i++) {
            int pogodak = input.nextInt();
            for (int j = 0; j <= (N * 2); j++) {
                if (pogodak == A[j][0]) {
                    A[j][1] += 1;
                }
            }
        }

        for (int i = 0; i <= (N * 2); i++) {
            if (A[i][1] >= K) {
                brojPoljaZaZameniti+=1;
            }
        }
        System.out.print(brojPoljaZaZameniti);

        /*    System.out.println();
        for (int i = 0; i <= (N * 2); i++) {
            System.out.print(A[i][1] + " ");
        }
         */
        System.out.println();
        for (int i = 0; i <= (N * 2); i++) {
            if (A[i][1] >= K) {
                System.out.print(A[i][0] + " ");
            }
        }
    }

}