Min = 1 Max = 2 * 10**9 A, B = map(int, input().split()) if A > B: print(Max - A) else: print(A - 1)