fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let mut n: Vec = n.trim().chars().map(|c| c.to_string()).collect(); n.sort_by(|a, b| b.cmp(a)); let len = n.len(); let mut border = len-1; let min = &n[len-1]; for i in 2..len { if min < &n[len-i] { border = len-i; break; } } if border == len-1 { println!("-1"); } else { n.swap(border, border+1); println!("{}", n.join("")); } }