# coding: utf-8 N, K = map(int,input().split()) if N % 2 == 0: if K >= N//2:#1周してるか ans = N//2 else: ans = K+1 else: ans = K+1 print(ans)