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(); if n % 2 == 0 { println!("{}", std::cmp::min((k + 1) / 2 * 2, n / 2)); } else { println!("{}", std::cmp::min(k * 2, n)); } }