while True:
    try:
        input_string = input()
        sorted_list = sorted(input_string)
        dict, ans = {}, ''

        for item in sorted_list:
            if item not in dict:
                number = sorted_list.count(item)
                dict.setdefault(item, number)

        new_list = sorted(dict.items(), key=lambda items:(-items[1], items[0]))

        for item in new_list:
            ans += item[0]

        print(ans)
    except:
        break