@staticmethod
def a():
    (n, x) = map(int, sys.stdin.readline().split())
    print(min((x - 1), (n - x)))
@staticmethod
def a():
    (n, x) = map(int, sys.stdin.readline().split())
    print(min((x - 1), (n - x)))