#include <iostream>
using namespace std;

typedef unsigned long long ll;
const ll maxi = 1e18;

// kill as many as possible
void kill_max(const ll num, ll ar[3]){
  ll can_move = num;
  // attack 1
  ll tmp = 0;
  tmp = min(ar[1], can_move);
  can_move -= tmp;
  ar[1] -= tmp;
  ar[0] += tmp;

  // attack 2
  tmp = min(ar[2], can_move/2);
  can_move -= 2*tmp;
  ar[2] -= tmp;
  ar[0] += tmp;

  // attack1 again
  tmp = min(ar[2], can_move);
  ar[2] -= tmp;
  ar[1] += tmp;
}

void kill_min(const ll num,  ll ar[3]){
  // attack 2
  ll can_move = num;
  ll tmp = 0;
  tmp = min(ar[2], can_move);
  can_move -= tmp;
  ar[2] -= tmp;
  ar[1] += tmp;

  // attack 1
  tmp = min(ar[1], can_move);
  can_move -= tmp;
  ar[1] -= tmp;
  ar[0] += tmp;
}


int solve(const ll a, const ll b, bool fg){
  ll ta[3] = {0, 0, a};
  ll tb[3] = {0, 0, b};
  int cnt = 0;

  while(true){
    if (cnt %2 == 0){
      if (fg){
	kill_max(ta[1] + ta[2], tb);
      } else {
	kill_min(ta[1] + ta[2], tb);
      }
    } else {
      if (fg){
	kill_min(tb[1] + tb[2], ta);
      } else {
	kill_max(tb[1] + tb[2], ta);
      }
    }
    if (ta[0] == a || tb[0] == b){
      break;
    }
    cnt++;
  }
  return cnt;
}

int solve2(const ll a, const ll b, bool fg1, bool fg2){
  ll ta[3] = {0, 0, a};
  ll tb[3] = {0, 0, b};
  int cnt = 0;

  while(true){
    if (cnt %2 == 0){
      if (fg1){
	kill_max(ta[1] + ta[2], tb);
      } else {
	kill_min(ta[1] + ta[2], tb);
      }
    } else {
      if (fg2){
	kill_max(tb[1] + tb[2], ta);
      } else {
	kill_min(tb[1] + tb[2], ta);
      }
    }
    if (ta[0] == a || tb[0] == b){
      break;
    }
    cnt++;
  }
  return cnt;
}

int main(){
  ll n, m;
  cin >> n >> m;

  if (n >= m){
    if (n >= 2 * m){
      cout << 0 << endl;
    } else {
      cout << 2 << endl;
    }
  } else {
    if ( n * 2 <= m ){
      cout << 1 << endl;
    } else {
      //int mini = solve(n, m, false);
      //mini = min(mini, solve(n, m, true));
      //cout << mini << endl;


      int a = solve2(n, m, false, true);
      int b = solve2(n, m, true, false);
      int c = solve2(n, m, false, false);
      int d = solve2(n, m, true, true);
      
      ///cout << mini <<" " << min(c, d) << endl;
      cout << min(min(a, b), min(c, d)) << endl;



    }
  }

  return 0;
}

