#!/usr/bin/env python # coding: utf-8 def ri(): return int(input()) def rl(): return list(input().split()) def rli(): return list(map(int, input().split())) def solve(x): last = x[-1] for i in range(len(x)-2, -1, -1): if x[i] == last: continue if i == 0 and last == '0': return -1 return "".join(x[:i]+[x[i+1]]+[x[i]]+x[i+2:]) return -1 def main(): x = list(input()) x.sort(reverse=True) # print(x) ans = solve(x) print(ans) if __name__ == '__main__': main()