a=sorted(map(int,input())) if a[-2]==0:print(-1) elif a[0]==a[-1]:print(-1) else: k=1 while a[0]==a[k]:k+=1 a[k]+=a[k-1];a[k-1]=a[k]-a[k-1];a[k]-=a[k-1];print(''.join(list(map(str,input()))[::-1]))