# coding: utf-8 # Your code here! import sys read = sys.stdin.read readline = sys.stdin.readline n,k = list(map(int,read().split())) if n%2==0: print(min(k+1,n//2)) else: print(min(k+1,n))