use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let n: i32 = iter.next().unwrap().parse().unwrap(); let k: i32 = iter.next().unwrap().parse().unwrap(); let x = if n % 2 == 0 { n / 2 } else { n }; if k % 2 == 0 { println!("{}", std::cmp::min(k + 1, x)); } else { println!("{}", std::cmp::min((k + 1) / 2 * 2, x)); } }