while True:
    try:
        strings = input().split()
        # print(strings)
        str_list = []
        for str in strings:
            if strings.count(str) >= 3:
                str_list.append(str)
        str_dict = {}
        for i in set(str_list):
            str_dict[i] = strings.count(i)
        # print(str_dict)
        # 通过-x[1], x[0]的双重排序,实现先按照出现次数逆序排序,再按照字母编码先后顺序排序
        str_dict_corted = sorted(str_dict.items(), key=lambda x: (-x[1], x[0]))
        # print(str_dict_corted)
        for j in str_dict_corted:
            print(j[0])

    except Exception as e:
        break