s = input() # 将输入的字符串转换成字典 sd = {} for i in s: sd[i] = sd.get(i,0) +1 # print(sd) # {'a': 2, 'd': 3, 'c': 3} # 根据value值对字典排序,如果value值相同,则根据keys升序排序 # item[1]降序,item[0]升序 sd_new = dict(sorted(sd.items(),key=lambda item:(-item[1],item[0]))) for key in sd_new.keys(): print(key,end='')