x, y = map(int,input().split()) print((y ^ ((x + 4) % 12) ^ ((x - 4) % 12)) % 12)