N, K = map(int, input().split()) if N % 2 == 0: print(min(N // 2, 1 + K)) else: print(min(N, 1 + K))