N,K = map(int,input().split()) #1,3,5,7 #2,4,6,8 if N % 2== 1: print(min(K+1,N)) else: print(min(K+1,N//2))