import java.util.Scanner;

public class Pikado {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),k = sc.nextInt(),z,br=0;
        int[] q = new int[2*n+1];
        for (int i = 0; i < 2*n+1; i++) {
            q[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            z = sc.nextInt();
            q[z+n] += 1;
            if (q[z+n]==k)
                br++;
        }
        System.out.println(br);
        for (int i = 0; i < 2*n+1; i++) {
            if (q[i] >= k)
            {
                System.out.print(i - n + " ");
            }
        }
    }
}