while True:
    try:
        strings = input()
        dict_char = {}
        for i in strings:
            dict_char[i] = strings.count(i)
        # print(dict_char)
        dict_char_sorted = sorted(dict_char.items(), key=lambda x: x[1], reverse=True)
        # print(dict_char_sorted)
        char_counts = []
        for j in dict_char_sorted:
            if j[1] not in char_counts:
                char_counts.append(j[1])
        # print(char_counts)
        chars = []
        for k in char_counts:
            temp = []
            for v in dict_char_sorted:
                if v[1] == k:
                    temp.append(v[0])
            chars.append(temp)
        # print(chars)
        result = ''
        for x in chars:
            result += ''.join(sorted(x))
        print(result)

    except:
        break