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