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)
}

C++: #include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, b, e) for (intmax_t i = (b), i##_limit = (e); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class Container>
struct reverse_t {
    Container &c;
    reverse_t(Container &c) : c(c) {}
    auto begin() { return c.rbegin(); }
    auto end() { return c.rend(); }
};

template <class Container>
auto reversed(Container &c) {
    return reverse_t<Container>(c);
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(10);

    var(intmax_t, x, y);

    vector<intmax_t> fib(40);
    fib[0] = fib[1] = 1;
    rep(i, 2, 40) fib[i] = fib[i - 1] + fib[i - 2];

    const auto res = makeFixPoint([&](auto rec, size_t i, intmax_t max_y, intmax_t max_x, intmax_t min_y, intmax_t min_x, intmax_t color) -> intmax_t {
        if (min_y <= y && y <= max_y && min_x <= x && x <= max_x) return color;
        intmax_t ret;
        if (i % 4 == 1) { // right
            ret = rec(i + 1, min_y + fib[i] - 1, max_x + fib[i], min_y, max_x + 1, (color + 1) % 3);
        } else if (i % 4 == 2) { // up
            ret = rec(i + 1, max_y + fib[i], max_x, max_y + 1, max_x - fib[i] + 1, (color + 1) % 3);
        } else if (i % 4 == 3) { // left
            ret = rec(i + 1, max_y, min_x - 1, max_y - fib[i] + 1, min_x - fib[i], (color + 1) % 3);
        } else { // down
            ret = rec(i + 1, min_y - 1, min_x + fib[i] - 1, min_y - fib[i], min_x, (color + 1) % 3);
        }
        return ret;
    })(1, 0, 0, 0, 0, 0);

    output(res + 1);

    return 0;
}

C++: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 50

enum Type{
	East,
	North,
	West,
	South,
};

struct Info{

	void set(int arg_left,int arg_right,int arg_top,int arg_under,int arg_color){
		left = arg_left;
		right = arg_right;
		top = arg_top;
		under = arg_under;
		color = arg_color;
	}

	ll left,right,top,under;
	int color;
};

int colors[3] = {1,2,3};
Type type_array[4] = {South,East,North,West};
Info info[SIZE];


int main(){

	info[0].set(0,0,0,0,1);
	info[1].set(1,1,0,0,2);

	ll pre_pre = 1,pre = 1;

	for(int i = 2; i < SIZE; i++){

		info[i].color = colors[i%3];

		ll size = pre_pre+pre;

		Type dir = type_array[i%4];

		switch(dir){
		case South:

			info[i].top = info[i-1].under-1;
			info[i].left = info[i-1].left;
			info[i].under = info[i].top-size+1;
			info[i].right = info[i].left+size-1;

			break;

		case East:

			info[i].left = info[i-1].right+1;
			info[i].under = info[i-1].under;
			info[i].top = info[i].under+size-1;
			info[i].right = info[i].left+size-1;

			break;

		case North:

			info[i].right = info[i-1].right;
			info[i].under = info[i-1].top+1;
			info[i].top = info[i].under+size-1;
			info[i].left = info[i].right-size+1;

			break;

		case West:

			info[i].right = info[i-1].left-1;
			info[i].top = info[i-1].top;
			info[i].under = info[i].top-size+1;
			info[i].left = info[i].right-size+1;

			break;
		}

		pre_pre = pre;
		pre = size;
	}

	ll x,y;

	scanf("%lld %lld",&x,&y);

	for(int i = 0; i < SIZE; i++){

		if(x >= info[i].left && x <= info[i].right && y >= info[i].under && y <= info[i].top){

			printf("%d\n",info[i].color);
			return 0;
		}
	}

	return 0;
}