using System; using System.Collections.Generic; using System.Linq; public class yukicoder { public static void Main() { double[] foo = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); double a = foo[0]; double b = foo[1]; if(b == 0 || b > a) { Console.WriteLine(0); } else if(a % 2 != 0 && b == Math.Ceiling(a / 2)) { Console.WriteLine(a - 1); } else if(b >= 1 && b <= a) { Console.WriteLine(a - 2); } } }