#coding: utf-8 ##yuki_39 s=raw_input() ls=list(s) lsw=ls[:] lst=ls[:] lst.sort() x=lst[-1] lst_temp=[] while lsw[0]==x: lst_temp.append(lsw[0]) del(lsw[0]) i=len(lsw)-1 while i>=0: if lsw[i]==x: idx=i break i-=1 lsw[0],lsw[idx]=x,lsw[0] resl=lst_temp+lsw print "".join(resl)