n,k = map(int,input().split(' ')) if k <= 0 or n < k: print(n) elif 2 * k - 1 == n: print(n-1) else: print(n-2)