Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1,  - 1)], [( - 1,  - 1), (2,  - 1)], [(2,  - 1), (2, 2)] and so on. Thus, this infinite spiral passes through each integer point of the plane.

Valera the horse lives on the plane at coordinates (0, 0). He wants to walk along the spiral to point (x, y). Valera the horse has four legs, so he finds turning very difficult. Count how many times he will have to turn if he goes along a spiral from point (0, 0) to point (x, y).


-----Input-----

The first line contains two space-separated integers x and y (|x|, |y| ≤ 100).


-----Output-----

Print a single integer, showing how many times Valera has to turn.


-----Examples-----
Input
0 0

Output
0

Input
1 0

Output
0

Input
0 1

Output
2

Input
-1 -1

Output
3

Difficulty: interview

Starter code:

Solutions:
3

from math import sin, cos, pi, atan2

x, y = tuple(map(int, input().split()))
if (x, y) in ((0, 0), (1, 0)):
    print(0)
elif x >= 1 and -x + 1 < y <= x:
    print(1 + 4 * (x - 1))
elif x < 0 and x <= y < -x:
    print(3 + 4 * (-x - 1))
elif y > 0 and -y <= x < y:
    print(2 + 4 * (y - 1))
else:
    print(-4 * y)


l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)


(x, y) = list(map(int, input().split()))

if y >= x and y < -x: print(-4*x-1)
elif y > x and y >= -x: print(4*y-2)
elif y <= x and y > 1-x: print(4*x-3)
elif y < x and y <= 1-x: print(-4*y)
else: print(0)


x, y = map(int, input().split())
u, v = abs(x), abs(y)
a = max(u, v)
s = 4 * (a - 1)

if u >= v and x > 0 and y > 1 - a: s += 1
elif v >= u and y > 0: s += 2
elif u >= v and x < 0: s += 3
elif v >= u and y < 0: s += 4

print(s if a > 0 else 0) 


def main():
    a,b=list(map(int,input().split()))
    if(a==0 and b==0):
        return 0
    x=0
    y=0
    step=1
    rep=0
    direction=0
    ans=0
    while(x!=a or y!=b):
        if(direction==0):
            for i in range(step):
                x+=1
                if(x==a and y==b):
                    return ans
            direction=1
            ans+=1
        elif(direction==1):
            for i in range(step):
                y+=1
                if(x==a and y==b):
                    return ans
            direction=2
            step+=1
            ans+=1
        elif(direction==2):
            for i in range(step):
                x-=1
                if(x==a and y==b):
                    return ans
            direction=3
            ans+=1
        else:
            for i in range(step):
                y-=1
                if(x==a and y==b):
                    return ans
            direction=0
            step+=1
            ans+=1
print(main())      
        


#4304263	 Aug 17, 2013 7:17:58 PM	fuwutu	 279A - The Point on the Spiral	 Python 3	Accepted	 124 ms	 0 KB
l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)


x,y=input().split()
x,y=int(x),int(y)
if x==y==0:
    print(0)
if y>=-x and y>x:
    print(4*y-2)
if x+y<0 and y>=x:
    print(4*abs(x)-1)
if y<x and x+y<=1:
    print(4*abs(y))
if x+y>1 and y<=x:
    print(4*x-3)
    


x, y = list(map(int, input().split()))
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]

def onl(x1, y1, x2, y2):
    if x1 == x2:
        return x == x1 and y in range(min(y1, y2), max(y1, y2) + 1)
    elif y1 == y2:
        return y == y1 and x in range(min(x1, x2), max(x1, x2) + 1)

def sp(cx, cy, t):
    l = t // 2 + 1
    nx, ny = cx + dx[t % 4] * l, cy + dy[t % 4] * l
    return t if onl(cx, cy, nx, ny) else sp(nx, ny, t + 1)

print(sp(0, 0, 0))



s = input().split()
x = (int(s[0]))
y = (int(s[1]))

dirx = [1,0,-1,0]
diry = [0,1,0,-1]

if x==0 and y==0:
    print(0)
else:
    cx = 0
    cy = 0
    dir = 0
    steps = 1
    count = 0
    done = False
    while not done:
        for i in range(steps):
            cx+=dirx[dir]
            cy+=diry[dir]
            if cx==x and cy==y:
                print(count)
                done = True
                break
        count+=1
        dir = (dir+1)%4
        if dir == 0 or dir==2:
            steps+=1

l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)

l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)

#WsSc0L
x,y = map(int,input().split())
if y>x and x>=-y: print(y*4-2)
elif y<x and x<=-y+1: print(-y*4)
elif y<=x and x>-y+1: print(x*4-3)
elif y>=x and x<-y: print(-1-4*x)
else: print(0)

def main():
    x, y = list(map(int, input().split()))
    r, t = max(abs(x), abs(y)), 0
    if x == r == 1 - y:
        t = 4
    elif x == r > -y:
        t = 3
    elif y == r > x:
        t = 2
    elif -x == r > y:
        t = 1
    print(({(0, 0): 0, (1, 0): 0, (1, 1): 1, (0, 1): 2, (-1, 1): 2, (-1, 0): 3, (-1, -1): 3,
           (0, -1): 4, (1, -1): 4}[x, y] if r < 2 else r * 4 - t))


def __starting_point():
    main()

__starting_point()

l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)


dest = list(map(int, input().split()))

side_len = 0
pos = [0, 0]
turns = 0

while True:
    side_len += 1
    if dest[1] == pos[1] and pos[0] <= dest[0] <= pos[0] + side_len:
        break
    turns += 1
    pos[0] += side_len
    if dest[0] == pos[0] and pos[1] <= dest[1] <= pos[1] + side_len:
        break
    turns += 1
    pos[1] += side_len
    side_len += 1
    if dest[1] == pos[1] and pos[0] >= dest[0] >= pos[0] - side_len:
        break
    turns += 1
    pos[0] -= side_len
    if dest[0] == pos[0] and pos[1] >= dest[1] >= pos[1] - side_len:
        break
    turns += 1
    pos[1] -= side_len

print(turns)





l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)



U=1
D=-1
x,y=map(int,input().split())
k=A=B=0
while 1:
	a,b=U,B;k+=1
	if (A<=x<=a or a<=x<=A)and(B<=y<=b or b<=y<=B):break
	A=a;b=U;k+=1
	if (A<=x<=a or a<=x<=A)and(B<=y<=b or b<=y<=B):break
	B=b;a=D;k+=1
	if (A<=x<=a or a<=x<=A)and(B<=y<=b or b<=y<=B):break
	A=a;b=D;k+=1
	if (A<=x<=a or a<=x<=A)and(B<=y<=b or b<=y<=B):break
	A,B=a,b
	U+=1;D-=1
if k<1:k=1
print(k-1)

'''input
37 -100
'''
p = [(0, 0)]
a, b = 0, 0
c = 1
while c < 202:
	for i in range(c-1):
		a += 1
		p.append((a, b))
	p.append((a+1, b, "*"))
	a += 1
	for j in range(c-1):
		b += 1
		p.append((a, b))
	p.append((a, b+1, "*"))
	b += 1
	for k in range(c):
		a -= 1
		p.append((a, b))
	p.append((a-1, b, "*"))
	a -= 1
	for l in range(c):
		b -= 1
		p.append((a, b))
	p.append((a, b-1, "*"))
	b -= 1
	c += 2
x, y = list(map(int, input().split()))
if (x, y) in p:
	z = p.index((x, y))
elif (x, y, "*") in p:
	z = p.index((x, y, "*"))
t = 0
for w in p[:z]:
	if len(w) == 3:
		t += 1
print(t)











#4304263	 Aug 17, 2013 7:17:58 PM	fuwutu	 279A - The Point on the Spiral	 Python 3	Accepted	 124 ms	 0 KB
l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)


from math import floor

def main(xx, yy):
    if xx == 0 and yy == 0:
        return 0
    if xx == 1 and yy == 0:
        return 0
    x = 0
    y = 0
    i = 0
    g = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    while not (x == xx and y == yy):
        prev_x = x
        prev_y = y
        x += (int(floor(i / 2) + 1) * g[i % 4][0])
        y += (int(floor(i / 2) + 1) * g[i % 4][1])
        i += 1
        if xx >= x and xx <= prev_x and yy >= y and yy <= prev_y:
            return i - 1
        if xx <= x and xx >= prev_x and yy <= y and yy >= prev_y:
            return i - 1
    return i - 1

print(main(*list(map(int, input().split(' ')))))


'''l = [[(0, 0), (1, 0)],
     [(1, 0), (1, 1)],
     [(1, 1), (-1, 1)],
     [(-1, 1), (-1, -1)],
     [(-1, - 1), (2, -1)],
     [(2, -1), (2, 2)]]
'''
'''
pattern er shudhone na paria
last e net theke copy marcha
pattern copy marcha re.
'''
x,y = list(map(int, input().split()))
if y >= x and y < -x:
    print(-4*x-1)
elif y > x and y >= -x:
    print(4*y-2)
elif y <= x and y > 1-x:
    print(4*x-3)
elif y < x and y <= 1-x:
    print(-4*y)
else:
    print(0)


x,y = map(int, input().split())

isCorner = (x == y) or (-x == y and y > 0) or (y == -x + 1 and x is not 0)


reachX = (0 if x == 0 else 1+(x-1)*4 if x > 0 else 3 + (abs(x) - 1)*4)
reachY = (0 if y == 0 else 2+(y-1)*4 if y > 0 else abs(y)*4)
if isCorner:
    print(min(reachX,reachY))
else:
    print(max(reachX,reachY))

l = input().split(' ')
x, y = int(l[0]), int(l[1])
if y <= 0 and x >= 1 + y and x <= 1 - y:
    print((-y) * 4)
elif x > 0 and y >= 2 - x and y <= x:
    print(x * 4 - 3)
elif y > 0 and x >= -y and x <= y - 1:
    print(y * 4 - 2)
elif x < 0 and y >= x and y <= -1 - x:
    print((-x) * 4 - 1)
else:
    print(0)


x,y=input().split()
x=int(x)
y=int(y)
p,q,z,i,j=0,0,0,1,1
def GT(n):
	t=0
	for i in range(1,n+1):
		if(i%2!=0):
			t+=i
		else:
			t+=(-i)
	return t
while (1):
	x1,y1=max(GT(i),GT(i-1)),min(GT(i),GT(i-1))
	x2,y2=max(GT(j),GT(j-1)),min(GT(j),GT(j-1))
	if(z%2==0):
		p=GT(i)
		i+=1
	if(z%2!=0):
		q=GT(j)
		j+=1
	z+=1
	if(x>=y1 and x<=x1 and y==q):
		break
	if(y>=y2 and y<=x2 and x==p):
		break
if((x==0 and y==0)or(x==1 and y==0)):
	print(0)
else:	
	print(z)


# python 3
"""
From tutorial: The starting position can be anywhere with a footprint. The footprints can be categorized into 3 types.

only L s
only R s
R s followed by L s

In case 1, we end in the left of all footprints.
In case 2, we end in the right of all footprints.
In case 3, we either end in the rightmost R or the leftmost L

Mine is different from the tutorial, based on intuition, hard to prove its correctness.
"""


def point_on_spiral(x_int, y_int) -> int:
    if x_int == 0 and y_int == 0 or x_int == 1 and y_int == 0:
        return 0
    count = 0
    x_prev, y_prev = 0, 0
    while True:
        spiral, count_mod_4 = divmod(count + 4, 4)
        if count_mod_4 == 0:
            x_curr, y_curr = spiral, -(spiral - 1)
        elif count_mod_4 == 1:
            x_curr, y_curr = spiral, spiral
        elif count_mod_4 == 2:
            x_curr, y_curr = -spiral, spiral
        else:
            x_curr, y_curr = -spiral, -spiral
        dist_to_prev = abs(x_int - x_prev) + abs(y_int - y_prev)
        dist_to_curr = abs(x_int - x_curr) + abs(y_int - y_curr)
        dist_prev_curr = abs(x_curr - x_prev) + abs(y_curr - y_prev)

        if dist_to_curr + dist_to_prev == dist_prev_curr:
            # print(x_prev, y_prev), (x_curr, y_curr), (x_int, y_int)
            return count
        count += 1
        x_prev, y_prev = x_curr, y_curr


def __starting_point():
    """
    Inside of this is the test. 
    Outside is the API
    """
    x, y = list(map(int, input().split()))

    print(point_on_spiral(x, y))

__starting_point()