s = input() if s.count('0') >= len(s)-1: res = -1 else: s1 = list(s) if len(set(s1)) == 1: res = -1 else: s1.sort() sw = '' for i in range(len(s1)-1): if s1[i] != s1[i+1]: sw = s1[i] s1[i] = s1[i+1] s1[i+1] = sw break else: pass s1.reverse() res = ''.join(s1) print(res)