n,k=map(int,input().split()) ans=k+1 if n&1:ans=min(ans,n) else:ans=min(ans,n>>1) print(ans)