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