while True:
try:
a = input()
s = sorted(set(a))
ss = sorted(s,key=lambda x:a.count(x),reverse=True)
print(''.join(ss))
except:
break
while True:
try:
a = input()
s = sorted(set(a))
ss = sorted(s,key=lambda x:a.count(x),reverse=True)
print(''.join(ss))
except:
break