import sys input=lambda: sys.stdin.readline().rstrip() n,k=map(int,input().split()) if n%2==0: print(min(n//2,k+1)) else: print(min(n,k+1))