while True:
    try:
        m = input()
        s = sorted(m,key=ord)
        string = ''
        result = []
        for i in s:
            if i.isalpha() or i.isdigit() or i == ' ':
                if i not in string:
                    string += i

        for i in string:
            result.append(s.count(i))

        result.sort(reverse=True)
        sort_s = ''
        for i in range(len(result)):
            for j in s:
                if result[i] == s.count(j) and j not in sort_s:
                    sort_s += j
        print(sort_s)
    except:
        break