import java.util.*;
public class DemoTest5 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextLine()) { // 注意 while 处理多个 case
int a =in.nextInt();
int[] arr =new int[a];
for(int i=0;i<a;i++){
arr[i]=in.nextInt();
}
int c= in.nextInt();
solve(arr,c);
}
}
private static void solve(int[] arr,int c) {
HashMap<Integer,Integer> map = new HashMap<>();
for(int i = 0;i<arr.length;i++){
map.put(arr[i],map.getOrDefault(arr[i],0)+1);
}
int count = 0;
for(Map.Entry<Integer,Integer> entry:map.entrySet()){
if(entry.getValue()>=c){
count++;
}
}
if(count == 0){
System.out.println(0);
return;
}
System.out.println(count);
map.entrySet().stream().filter(entry-> entry.getValue()>=c).sorted((e1, e2)-> {
if(Objects.equals(e2.getValue(), e1.getValue())){
return e1.getKey()-e2.getKey();
}else{
return e2.getValue()-e1.getValue();
}}).forEach(entry->{
System.out.println(entry.getKey());
});
}
}