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