l,c = map(int, input().split())
if l<c: print(c-2)
else: print(1999999999-c)