N=list(map(int,input())) n=len(N) def solve(i,p): global a,A if p==1: for j in range(i+1,n): if v[j]==0 and N[j]!=N[i]: v[j]=1 a+=N[j]*10 solve(j,2) a-=N[j]*10 v[i]=0 if p==2: for j in range(i+1,n): if v[j]==0 and N[j]==N[i]: v[j]=1 a+=N[j]*1 solve(j,3) a-=N[j]*1 v[i]=0 if p==3: A=max(A,a) for j in range(n): if v[j]==0: v[j]=1 a+=N[j]*100 solve(j,1) a-=N[j]*100 v[i]=0 return a=0 A=0 v=[0]*n v[0]=1 for i in range(n): if N[i]!=0: v[i]=1 a+=N[i]*100 solve(i,1) a-=N[i]*100 v[i]=0 print(A)