n, k = map(int, input().split()) l = k - 1 r = n - k if r >= l: print(k + 1) else: print(k - 1)