A, B = [int(i) for i in input().split()] if A < B: print(max(A, B) - 2) else: print(2000000000 - A )