import sys
from collections import Counter

words = []

# 读取输入的所有单词
for line in sys.stdin:
    words.extend(line.split())

cnt = Counter(words)

res = []
for word, count in cnt.items():
    if count >= 3:
        res.append((word,count))


res.sort(key=lambda x: (-x[1], x[0]))

for w in res:
    print(w[0])