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