import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 *
 * @author Marija PC
 */
public class Z1 {

 
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n,k;
        List<Integer> niz  = new CopyOnWriteArrayList<Integer>();
         Set<Integer> niz2  = new HashSet<Integer>();
        
        n = input.nextInt();
        k = input.nextInt();
        
        
        for(int i=0; i<n; i++){
            int j = input.nextInt();
            niz.add(j);
        }
        
        int brojac;
        int brojac2=0;
        
        for(int i: niz){
               brojac = Collections.frequency(niz, i);
               
               if(brojac >= k){
                   brojac2++;
                   niz2.add(i);
                 
                  niz.removeAll(Collections.singleton(i));
                  
               }
        }
        
        
        System.out.println(brojac2);
        for(int i: niz2){ System.out.print(i + " ");}
        
        
        
                
        
    }
    
}