use std::cmp; fn main() { let mut nk = String::new(); std::io::stdin().read_line(&mut nk).ok(); let mut nk = nk.trim().split_whitespace(); let n: u64 = nk.next().unwrap().parse().unwrap(); let k: u64 = nk.next().unwrap().parse().unwrap(); if n % 2 == 0 { println!("{}", cmp::min(n / 2, 1 + k)); } else { println!("{}", cmp::min(n, 1 + k)); } }