a,b = map(int,input().split()) x = a//4 y = b//4 #if x%4 != 0: # x -= 1 # y -= 1 if x == 0: if y == 1: z = 2 else: z = 1 elif x == 1: if y == 2: z = 0 else: z = 1 else: if y == 0: z = 1 else: z = 0 w = a%4 #print(z,w) print(z*4+w)