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