while True:
    chars = []
    total = []
    ret = {}
    try:
        s = input()
    except EOFError:
        break
    for c in set(s):
        if c not in chars:
            chars.append(c)
            count = s.count(c)
            if count not in ret:
                ret[count] = [c]
                total.append(count)
            else:
                ret[count].append(c)
    total.sort(reverse=True)
    for i in total:
        ret[i].sort()
        for c in ret[i]:
            print(c, end='')
    print("")