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