x, y = gets.chomp.split.map(&:to_i)

color, direction = 0, -1
if [x, y] != [0, 0]
    rc, sq = {x:0, y:0, w:1, h:1}, nil
    while true
        color, direction = (color + 1) % 3, direction = (direction + 1) % 4
        case direction
        when 0
            sq = {x:rc[:x] + rc[:w], y:rc[:y], w:rc[:h], h:rc[:h]}
            rc = {x:rc[:x], y:rc[:y], w:rc[:w] + sq[:w], h:rc[:h]}
        when 1
            sq = {x:rc[:x], y:rc[:y] + rc[:h], w:rc[:w], h:rc[:w]}
            rc = {x:rc[:x], y:rc[:y], w:rc[:w], h:rc[:h] + sq[:h]}
        when 2
            sq = {x:rc[:x] - rc[:h], y:rc[:y], w:rc[:h], h:rc[:h]}
            rc = {x:sq[:x], y:sq[:y], w:sq[:w] + rc[:w], h:sq[:h]}
        when 3
            sq = {x:rc[:x], y:rc[:y] - rc[:w], w:rc[:w], h:rc[:w]}
            rc = {x:sq[:x], y:sq[:y], w:sq[:w], h:sq[:h] + rc[:h]}
        end
        break if x.between?(sq[:x], sq[:x] + sq[:w] - 1) && y.between?(sq[:y], sq[:y] + sq[:h] - 1)
    end
end
puts color + 1
