import sys from collections import Counter for line in sys.stdin: c=Counter(line.strip()) d={i:[] for i in set(c.values())} for k,v in c.items(): d[v].append(k) dd=dict(sorted(d.items(), key=lambda _ :_[0],reverse=True)) ss='' for k,v in dd.items(): dd.update({k:sorted(v,reverse=False)}) ss+=''.join(dd[k]) print(ss)