a, b = map(int, input().split()) if a < b: c = b - 2 else: c = 2000000000 - a print(c)