A,B=map(int,input().split()) print((2*10**9-B-1,B-2)[A