X = input() t = sorted(X, reverse=True) a, b = t[-2], t[-1] t[-2], t[-1] = b, a Y = ''.join(t) if X == Y or Y[0] == '0': print(-1) else: print(Y)