n, k = map(int, input().split()) if n % 2 == 1: print(min(n, 1+k)) else: print(min(n//2, 1+k))