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 <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <cmath>
#include <functional>
#include <set>

using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
//region
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (b); i >= (b); --i)
#define rep(i, n) for (unsigned i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n)-1; i >= 0; --i)
#define repr1(i, n) for (int i = (n); i > 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define mset(v, n) std::memset((v), n, sizeof(v))
#define BIT(N) (1LL << (N))
#define each(i, v) for (auto&& i : (v))
#define unless(f) if(!(f))
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using vint = vector<int>;
using vlong = vector<ll>;
using vstr = vector<string>;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpll = vector<pll>;
using vvi = vector<vint>;
using vvl = vector<vlong>;
template<typename T> using VV = vector<vector<T>>;
vector<string> split(const string &s, const string &delim) {
  vector<string> res;
  uint pos = 0;
  while (true) {
    const size_t found = s.find(delim, pos);
    if (found < 0) {
      res.push_back(s.substr(pos));
      break;
    }
    res.push_back(s.substr(pos, found - pos));
    pos = found + delim.size();
  }
  return res;
}
template<typename T> string join(vector<T> &vec, const string &sep) {
  size_t size = vec.size();
  if (!size) return "";
  std::stringstream ss;
  for (int i = 0; i < size - 1; i++)
    ss << vec[i] << sep;
  ss << vec[size - 1];
  return ss.str();
}
template<typename T> std::istream &operator>>(std::istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template<typename Iter> inline void print(const Iter &first, const Iter &last, const std::string &d, bool endline) {
  cout << *first;
  for (Iter iter = first + 1; iter < last; ++iter) {
    cout << d << *iter;
  }
  if (endline) cout << "\n";
}
constexpr ll powmod(ll a, ull b, uint p) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a % p;
    a = a * a % p;
    b >>= 1u;
  }
  return res;
}

constexpr ll pow(ll a, ull b) {
  ll res = 1;
  while (b > 0) {
    if (b % 2) res = res * a;
    a = a * a;
    b >>= 1u;
  }
  return res;
}

template<class T> bool chmax(T &a, const T &b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, const T &b) { return a > b ? (a = b, true) : false; }
template <typename T> void bsort(vector<T>& v) { std::sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T>& v) { std::sort(v.begin(), v.end(), std::greater<T>()); }
struct iii {
    iii() {
      cin.tie(nullptr); cout.tie(nullptr);
      std::ios::sync_with_stdio(false);
      cout << std::fixed << std::setprecision(16);
    }
} init;
//endregion

void solve();

int main() {
  int t = 1;
  //scanf("%d", &t);
  //cin >> t;
  rep(i, t) solve();
  return 0;
}


void solve() {
  // 1 1 2 3 5 8 13
  vector<int> vec = {1, 1};
  int x, y; std::cin >> x >> y;
  // 1: right (east)
  // 2: top (north)
  // 3: left (west)
  // 0: bottom (south)

  int right = 0, left = 0, top = 0, bottom = 0;
  if (x == 0 && y == 0) {
    std::cout << 1 << std::endl;
    return;
  }
  for (int num = 1; ; ++num) {
vec.push_back(
  *(vec.end() - 1) +
  *(vec.end() - 2)
);
    switch (num % 4) {
      case 1:
        top = bottom + vec[num] - 1;
        left = right + 1;
        right = left + vec[num] - 1;
        break;
      case 2:
        left = right - vec[num] + 1;
        bottom = top + 1;
        top = bottom + vec[num] - 1;
        break;
      case 3:
        bottom = top - vec[num] + 1;
        right = left - 1;
        left = right - vec[num] + 1;
        break;
      case 0:
        right = left + vec[num] - 1;
        top = bottom - 1;
        bottom = top - vec[num] + 1;
        break;
    }
    //std::cerr << vector<string>{"R","Y","B"}[num%3] << ": [" << left << ", " << top << "], [" << right << ", " << bottom << "]" << std::endl;
    // left < right
    // bottom < top
    // std::cerr <<( left <= x) << " " <<  (x <= right) << " " << (bottom <= y) << " " << (y <= top) << "\n";
    if (left <= x && x <= right && bottom <= y && y <= top) {
      std::cout << num % 3 + 1 << "\n";
      return;
    }
  }
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int x,y,flag=0,count=0;
  cin>>x>>y;
  int xmin=0,ymin=0,xmax=0,ymax=0;
  std::vector<int> f(100);
  f[1]=1;
  f[2]=2;
  for(int i=3;i<f.size();i++){
    f[i]=f[i-1]+f[i-2];
  }
  while(flag==0){
    if(x==0&&y==0) break;
    else{
      count++;
      if(count%4==1) xmax+=f[count];
      else if(count%4==2) ymax+=f[count];
      else if(count%4==3) xmin-=f[count];
      else ymin-=f[count];
      if((x>=xmin&&x<=xmax)&&(y>=ymin&&y<=ymax))
        flag=count;
    }
  }
  int color=(flag%3)+1;
  cout<<color<<endl;
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
int x,y;cin >> x >> y;
int xmin,xmax,ymax,ymin;
xmin = ymin = 0;xmax = ymax = 1;
bool f = 1;int i;
for(i=0;f;i++) {
if(xmin<=x&&x<xmax&&ymin<=y&&y<ymax)f = 0;
if(i%4==0)xmax+=ymax-ymin;
else if(i%4==1)ymax+=xmax-xmin;
else if(i%4==2)xmin+=ymin-ymax;
else ymin+=xmin-xmax;
}
cout << (i-1)%3+1 << endl;
}