using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var k = int.Parse(line[1]); getAns(n, k); } static void getAns(int n, int k) { if (n == 1) { Console.WriteLine(1); return; } if (n == 2) { if (k == 1) Console.WriteLine(2); else Console.WriteLine(1); return; } if (n % 2 == 0) Console.WriteLine(k <= n / 2 ? n - 1 : n); else Console.WriteLine(k < (n + 1) / 2 ? n - 1 : n); } }