local s = io.read() local n = #s local t = {} for i = 1, n do t[i] = tonumber(s:sub(i, i)) end table.sort(t, function(a, b) return a > b end) if t[2] == 0 or t[1] == t[n] then print(-1) else for i = n, 2, -1 do if t[i] ~= t[i - 1] then t[i], t[i - 1] = t[i - 1], t[i] break end end print(table.concat(t)) end