T=sorted(range(N:=len(S:=input())),key=lambda x:S[x]);V=[0]*N;A=sorted(S);Z=[] for i in range(N): if V[i]<1: V[i]=1;C=[i] while V[u:=T[C[-1]]]<1:V[u]=1;C+=[u] while len(C)>1: if A[a:=C.pop()]