a, b = map(int, input().split()) N = 2000000000 if a > b: ans = N-b-1 else: ans = b-2 print(ans)