#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    ll N, S;
    cin >> S >> N;
    ll cnt = 0;
    while(N >= 2 * S) {
        if(N == S + 2) {
            N = S;
        }
       else if(N % 2 == 1) {
            N--;
        }
        else {
            N /= 2;
        }
        cnt++;
    }
    cout << cnt + (N - S + 1) / 2 << endl;
    return 0;
}

// 99123959998
