from collections import Counter o=Counter(input()) s=[[i,o[i]] for i in o] s.sort(key=lambda item:(-item[1],item[0])) for i in s: print(i[0],end='')