#[allow(unused_macros)] macro_rules! invec { ( $t:ty ) => {{ let mut s = String::new(); match std::io::stdin().read_line(&mut s) { Ok(0) => Vec::<$t>::new(), Ok(n) => s.trim().split_whitespace().map(|s| s.parse::<$t>().unwrap()).collect::>(), Err(_) => Vec::<$t>::new(), } }} } #[allow(unused_macros)] macro_rules! input { ( $($t:ty),* ) => {{ let mut s = String::new(); std::io::stdin().read_line(&mut s); let mut splits = s.trim().split_whitespace(); ($( { splits.next().unwrap().parse::<$t>().unwrap() }, )*) }} } fn beautiful(a: i64, b: i64, c: i64) -> bool { a != b && b != c && c != a && (a + b) % c == 0 && (b + c) % a == 0 && (c + a) % b == 0 } #[allow(unused_must_use)] #[allow(unused_variables)] fn solve() { let (a, b) = input!(i64, i64); let small = std::cmp::min(a, b); let big = std::cmp::max(a, b); if beautiful(small, big, big - small) { println!("{}", big - small); } else if beautiful(small, big, small + big) { println!("{}", small + big); } else { println!("-1"); } } fn main() { solve(); }