n = input() st = dict() for x in n: st[x]=st.get(x,0)+1 st = sorted(st.items(),key=lambda x:(x[1],-ord(x[0])),reverse=True) print(''.join([s[0] for s in st]))