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(); if let Some(p) = c.iter().position(|&x| x != c[0]) { if c[0] != '0' || p != c.len() - 1 { c.swap(p - 1, p); println!("{}", c.iter().rev().collect::()); return; } } println!("-1"); }