fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let mut c: Vec<_> = s.trim().chars().collect(); c.sort(); for i in 0..c.len() { if c[i] != c[0] && (i < c.len() - 1 || c[0] != '0') { c.swap(i, i - 1); println!("{}", c.iter().rev().collect::()); return; } } println!("-1"); }