n,k=map(int,input().split()) print(min(n,k+1)) if n%2==1 else print(min(n/2,k+1))