x = int(input())
y = int(input())
row1, pos1 = divmod(x - 1, 4)
row2, pos2 = divmod(y - 1, 4)
if row1 == row2:
if abs(pos1 - pos2) == 1 and pos1 // 2 == pos2 // 2:
print(1)
elif pos1 + pos2 == 4:
print(2)
else:
print(4)
else:
if abs(row1 - row2) == 1 and pos1 // 2 == pos2 // 2:
print(3)
else:
print(4)