# 思路:活用lambda函数进行多项排序 s = input() l = [] for i in set(s): l.append((i,s.count(i))) l.sort(key=lambda x:(-x[1],x[0])) for i in l: print(i[0],end="")