Загрузка данных


x = int(input())
y = int(input())

def info(n):
    row = (n - 1) // 4 + 1
    pos = (n - 1) % 4
    side = 'L' if pos < 2 else 'R'
    aisle = (pos % 2 == 1)
    return row, pos, side, aisle

rx, px, sx, ax = info(x)
ry, py, sy, ay = info(y)

if rx == ry and sx == sy and abs(px - py) == 1:
    print(1)
elif rx == ry and sx != sy and ax and ay:
    print(2)
elif abs(rx - ry) == 1 and sx == sy:
    print(3)
else:
    print(4)