#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
using ll = long long;

ll ans = INF;
void rec(ll x2, ll x1, ll y2, ll y1, ll cnt) {
    if (cnt > ans) return ;
    ll all = x2 + x1;
    if (y2 * 2 + y1 <= all) return void(ans = min(ans, cnt));
    rec(
        max(0LL, y2 - all),
        y1 + min(all, y2) - max(0LL, all - y2),
        x2, x1, cnt + 1
    );
    rec(
        y2 - max(0LL, all - y1 + 1) / 2,
        max(0LL, y1 - all) + max(0LL, all - y1) % 2,
        x2, x1, cnt + 1
    );
}

int main() {
    ll n, m; cin >> n >> m;
    rec(n, 0, m, 0, 0);
    cout << ans << endl;
    return 0;
}

