import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]= new int[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        int b[]=removeDuplicates(a.clone());
        int puta=0;
        int d[]= new int[b.length];
        int br=0;
        for (int i = 0; i < b.length; i++) {
            int c=count(a,b[i]);
            if(c>=k) {
                puta++;
                d[br]=b[i];
                br++;
            }
        }
        System.out.println(puta);
        for (int i = 0; i < puta; i++) {
            System.out.print(d[i]+" ");
        }

    }
    public static int count (int[] sampled, int val)
    {
        int count = 0;
        for (int i = 0; i < sampled.length; i++) {
            if (sampled[i] == val) {
                count++;
            }
        }
        return count;
    }
    public static int[] removeDuplicates(int[] arr){
        int end = arr.length;

        for (int i = 0; i < end; i++) {
            for (int j = i + 1; j < end; j++) {
                if (arr[i] == arr[j]) {
                    arr[j] = arr[end-1];
                    end--;
                    j--;
                }
            }
        }

        int[] whitelist = new int[end];
        System.arraycopy(arr, 0, whitelist, 0, end);
        return whitelist;
    }
}