a,*s=input()+'~' for b in s:a=max(a)+b;print(end=min(a))