import java.util.*;
public class Exercise22_7 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
TreeMap<Integer,Integer> treeMap = new TreeMap<Integer,Integer>();
int a = in.nextInt();
while(a!=0) {
if(treeMap.get(a)==null) {
treeMap.put(a,1);
}
else {
int integer = treeMap.get(a);
treeMap.put(a,++integer);
}
a = in.nextInt();
}
System.out.println(treeMap);
Set<Integer> set = treeMap.keySet();
Iterator<Integer> iterator = set.iterator();
int max = treeMap.get(iterator.next());
while(iterator.hasNext()) {
int aa = iterator.next();
if(treeMap.get(aa)>=max) {
max = treeMap.get(aa);
}
}
iterator = set.iterator();
while(iterator.hasNext()) {
int aa = iterator.next();
if(treeMap.get(aa)==max) {
System.out.print(aa + " ");
}
}
System.out.println();
}
}
public class Exercise22_7 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
TreeMap<Integer,Integer> treeMap = new TreeMap<Integer,Integer>();
int a = in.nextInt();
while(a!=0) {
if(treeMap.get(a)==null) {
treeMap.put(a,1);
}
else {
int integer = treeMap.get(a);
treeMap.put(a,++integer);
}
a = in.nextInt();
}
System.out.println(treeMap);
Set<Integer> set = treeMap.keySet();
Iterator<Integer> iterator = set.iterator();
int max = treeMap.get(iterator.next());
while(iterator.hasNext()) {
int aa = iterator.next();
if(treeMap.get(aa)>=max) {
max = treeMap.get(aa);
}
}
iterator = set.iterator();
while(iterator.hasNext()) {
int aa = iterator.next();
if(treeMap.get(aa)==max) {
System.out.print(aa + " ");
}
}
System.out.println();
}
}