X, Y = map(int, input().split()) if abs(X-Y)==8: print((min(X,Y)+4)%12) elif abs(X-Y)==4: m = min(X, Y) m += 12 print((m-4)%12)