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