while True:
try:
s = input()
result = {}
for i in s:
if i not in result:
result[i] = s.count(i)
output_list = sorted(result.items(), key = lambda d :(-d[1],d[0]))#这个排序的写法需要背诵,背诵起来。。。
#注意 sorted返回的结果会把字典变成元组了,需要取通过i[0]取其键值。
for i in output_list:
print(i[0], end = '')
print()
except:
break