#Tips:多重key排序,lambda x:后面跟括号,内部写key1,key2...

s=input()
ans="".join(sorted(set(s),key=lambda x:(-s.count(x),ord(x))))
print(ans)