X, Y = map(int, input().split()) print([(X + 4) % 12, (X + 8) % 12][1 - [(X + 4) % 12, (X + 8) % 12].index(Y)])