Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func parseToArray2d(lines []string) [][]int64 {
	var result [][]int64
	for _, line := range lines {
		var parsedLine []int64
		for _, element := range strings.Split(line, " ") {
			n, err := strconv.ParseInt(element, 10, 64)
			if err != nil {
				fmt.Printf("Error: element = %v\n", element)
			}
			parsedLine = append(parsedLine, n)
		}
		result = append(result, parsedLine)
	}
	return result
}

func pop(stack []int64) ([]int64, int64) {
	lenStack := len(stack)
	return stack[0:(lenStack - 1)], stack[lenStack-1]
}

func contains(s []int64, e int64) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	content := []string{}
	for scanner.Scan() {
		line := scanner.Text()
		content = append(content, line)
	}
	arr := parseToArray2d(content)
	x := arr[0][0]
	y := arr[0][1]

	if x == 0 && y == 0 {
		fmt.Println(1)
		return
	}

	filledRange := []int64{1, 0, 0, 0}
	direction := 0
	var prev int64 = 1
	var curr int64 = 1
	xSatisfied := false
	ySatisfied := false
	i := 1
	for ; i < 100; i++ {
		filledRange[direction%4] += curr
		direction++
		// fmt.Println(filledRange)

		if (x >= 0 && x <= filledRange[0]) || (x <= 0 && -x <= filledRange[2]) {
			xSatisfied = true
		}
		if (y >= 0 && y <= filledRange[1]) || (y <= 0 && -y <= filledRange[3]) {
			ySatisfied = true
		}

		if xSatisfied && ySatisfied {
			break
		}

		prev, curr = curr, prev+curr
	}

	fmt.Println(i%3 + 1)
}

Python: import copy
x,y = map(int,input().split())
color = 1
za = [0,0]
n = 0
m = 1
l = 1
d = 1
X = 0
Y = 0
while True:
    if za[0] <= x and za[0]+l-1 >= x and za[1] >= y and za[1]-l+1 <= y:
        print(color)
        break
    m = copy.deepcopy(l)
    l += n
    n = m
    color += 1
    if color > 3:
        color = 1
    if d == 1:
        za[0] += n
        za[1] = Y
        d = 2
    #print(za)
    elif d == 2:
        za[0] = X
        za[1] += l
        Y = za[1]
        d = 3
    elif d == 3:
        za[0] -= l
        za[1] = Y
        X = za[0]
        d = 4
    elif d == 4:
        za[0] = X
        za[1] -= n
        d = 1
    #print(za,X,Y,l,color)

Python: # AOJ 0409
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0409

xx, yy = list(map(int, input().split()))

fib = [1, 1]
a = 0
while a < 10000000:
    a = fib[-1] + fib[-2]
    fib += [a]

area = [[0, 0, 1]]
x, y = 0, 0
f1 = 0
f2 = 1
for n in range(1, len(fib)):
    a = fib[n]
    if n % 4 == 1:
        area += [[x + f2, y + f1, a]]
    elif n % 4 == 2:
        area += [[x - f1, y + a, a]]
    elif n % 4 == 3:
        area += [[x - a, y, a]]
    elif n % 4 == 0:
        area += [[x, y - f2, a]]
    f1 = f2
    f2 = a
    x, y = area[-1][0:2]

for n, floor in enumerate(area):
    x, y, a = floor
    if x <= xx < x + a and y - a < yy <= y:
        print(n % 3 + 1)
        break

Python: import sys
x,y = list(map(int, input().split()))

cnt = 1
xy = [0,0]
xy2 = [1,1]
if xy[0] <= x < xy2[0] and xy[1] <= y < xy2[1]:
    print(cnt)
    sys.exit(0)
while 1:
    if cnt % 4 == 1:
        xy2[0] += xy2[1] - xy[1]
    elif cnt % 4 == 2:
        xy2[1] += xy2[0] - xy[0] 
    elif cnt % 4 == 3:
        xy[0] -= xy2[1] - xy[1]
    elif cnt % 4 == 0:
        xy[1] -= xy2[0] - xy[0]
    if xy[0] <= x < xy2[0] and xy[1] <= y < xy2[1]:
        print((cnt % 3) + 1)
        break
    cnt += 1

Python: def search(x, y):
    x_min = 0
    y_min = 0
    x_max = 0
    y_max = 0
    f = 0
    f1 = 1
    f2 = 0
    p = 0
    while(True):
        if ( x_min <= x and x <= x_max and
             y_min <= y and y <= y_max  ): return p%3 + 1
        f = f1 + f2
        if ( p % 4 == 0 ):  x_max += f  # east
        elif ( p % 4 == 1 ): y_max += f # north
        elif ( p % 4 == 2 ): x_min -= f # west
        else:  y_min -= f               # south
        f2 = f1
        f1 = f
        p = p + 1

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

Python: import sys

point=list(map(int,input().split()))
if point[0]==0 and point[1]==0:
    print("1")
    sys.exit()
fiblist=[0,1,1]
maxpoint=[0,0]
minpoint=[0,0]
i=2
while True:
    if i%4==2 or i%4==3:
        maxpoint[i%2]+=fiblist[2]
    else:
        minpoint[i%2]-=fiblist[2]
    if minpoint[0]<=point[0] and maxpoint[0]>=point[0] and minpoint[1]<=point[1] and maxpoint[1]>=point[1]:
        print((i-1)%3+1)
        break
    fiblist[0]=fiblist[1]
    fiblist[1]=fiblist[2]
    fiblist[2]=fiblist[0]+fiblist[1]
    i+=1

Python: fib = [0, 1, 1]
for i in range(35):
    fib.append(fib[-1]+fib[-2])
x, y = map(int, input().split())
xn, xm, yn, ym = 0, 0, 0, 0
i = 2
color = 1
if (xn <= x <= xm) and (yn <= y <= ym):
    print(1)
    exit()
while True:
    if i % 4 == 2:
        xn += fib[i-1]
        xm += fib[i]
        yn += 0
        ym += fib[i-2]
    elif i % 4 == 3:
        xn -= fib[i-2]
        xm += 0
        yn += fib[i-1]
        ym += fib[i]
    elif i % 4 == 0:
        xn -= fib[i]
        xm -= fib[i-1]
        yn -= fib[i-2]
        ym += 0
    else:
        xn += 0
        xm += fib[i-2]
        yn -= fib[i]
        ym -= fib[i-1]
    color %= 3
    color += 1
    # print(xn, xm, yn, ym, i-2, color)
    if (xn <= x <= xm) and (yn <= y <= ym):
        print(color)
        break
    i += 1

Python: x, y = map(int, input().split())
tx, ty = 0, 0
a = 1
b = 1
ans = 1
while 1:
    if (tx,ty) == (x,y): break

    b += a
    tx += b-1
    ans += 1
    #print(tx-a+1, tx, "  ", ty, ty+a-1)
    if tx-a+1<=x<=tx and ty<=y<=ty+a-1: break

    a += b
    ty += a-1
    ans += 1
    #print(tx-b+1, tx, "  ", ty-b+1, ty)
    if tx-b+1<=x<=tx and ty-b+1<=y<=ty: break

    b += a
    tx -= b-1
    ans += 1
    #print(tx, tx+a-1, "  ", ty+a+1, ty)
    if tx<=x<=tx+a-1 and ty-a+1<=y<=ty: break

    a += b
    ty -= a-1
    ans += 1
    #print(tx, tx+b-1, "  ", ty, ty+b-1)
    if tx<=x<=tx+b-1 and ty<=y<=ty+b-1: break
print(ans%3 if ans%3 else 3)

Python: x,y = map(int,input().split())
left,right,up,down = 0,0,0,0
fiv1 = 0
fiv2 = 1
color = [1,2,3]
ans = 0
while not(left <= x <= right) or not(down <= y <=up):
  num = fiv1 + fiv2
  right += num
  fiv1 = fiv2
  fiv2 = num
  ans += 1
  
  if left <= x <= right and down <= y <= up:
    break
  num = fiv1 + fiv2
  up += num
  fiv1 = fiv2
  fiv2 = num
  ans += 1 

  if left <= x <= right and down <= y <= up:
    break
  num = fiv1 + fiv2
  left -= num
  fiv1 = fiv2
  fiv2 = num
  ans += 1

  if left <= x <= right and down <= y <= up:
    break  
  num = fiv1 + fiv2
  down -= num
  fiv1 = fiv2
  fiv2 = num
  ans += 1
print(color[ans%3])

Python: x,y = (int(_) for _ in input().split())
minX = minY = dir = 0
maxX = maxY = 1

while 1:
    if minX <= x and x < maxX and minY <= y and y < maxY:
        break
    if dir % 4 == 0:
	    maxX += max(maxX - minX,maxY - minY)
    elif dir % 4 == 1:
        maxY += max(maxX - minX, maxY - minY)
    elif dir % 4 == 2:
        minX -= max(maxX - minX, maxY - minY)
    else:
        minY -= max(maxX - minX, maxY - minY)
    dir += 1
print((dir % 3) + 1)

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

max_i = 0
max_j = 0
min_i = 0
min_j = 0
color = [1, 2, 3]
i = 0
while True :
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_j+1  - min_j
    max_i += l
    
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_i+1  - min_i
    max_j += l
    
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_j+1  - min_j
    min_i -= l
    
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_i+1  - min_i
    min_j -= l

print(ans)