fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let n: Vec = s.split_whitespace().flat_map(str::parse).collect(); println!( "{}", match n[0] { x if n[1] < 1 || x < n[1] => 0, x if x % 2 == 1 && n[1] == x / 2 + 1 => x - 1, x => x - 2, } ); }