p1 = int(input())
p2 = int(input())
r1, c1 = divmod(p1 - 1, 4)
r2, c2 = divmod(p2 - 1, 4)
left1 = c1 < 2
left2 = c2 < 2
same_row = r1 == r2
same_side = left1 == left2
near_rows = abs(r1 - r2) == 1
if same_row and same_side:
print(1)
elif same_row and c1 % 2 == 1 and c2 % 2 == 1:
print(2)
elif near_rows and same_side:
print(3)
else:
print(4)