using System; public class Hello { public static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var k = int.Parse(line[1]); int ans; if (k == 0 | k > n) ans = 0; else if (k == (n + 1) / 2) ans = n - 1; else ans = n - 2; Console.WriteLine(ans); } }