import java.util.*;
class KeyWord {
String word;
int count;
public KeyWord(String word, int count) {
this.word = word;
this.count = count;
}
}
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
Map<String, Integer> map = new HashMap<>();
String[] words = s.split(" ");
for (String word : words) {
map.put(word, map.getOrDefault(word, 0) + 1);
}
List<KeyWord> list = new ArrayList<>();
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() >= 3) {
list.add(new KeyWord(entry.getKey(), entry.getValue()));
}
}
list.sort((o1, o2) -> {
if (o1.count != o2.count) return o2.count - o1.count;
else return o1.word.compareTo(o2.word);
});
// Collections.sort(list, (o1, o2) -> {
// if (o1.count != o2.count) return o2.count - o1.count;
// else return o1.word.compareTo(o2.word);
// });
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i).word);
}
}
}