#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n = 0, x, y;
  cin >> x >> y;
  if (x >= y) {
    cout << abs(x - y) << endl;
  } else {
    while (x < y) {
      if (y % 2 == 0) {
        y = y / 2;
      } else {
        y = y + 1;
      }
      n++;
    }
    m = n + abs(x - y);
    cout << m << endl;
  }
}
