#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  if (m < n) {
    cout << n - m;
  } else {
    int counter = 0;
    int counter2 = 0;
    int min1 = 0;
    int minimum = 10000000;
    while (m > n) {
      if (m % 2 == 0) {
        m /= 2;
        counter++;
      } else {
        m++;
        counter++;
      }
    }
    cout << counter + n - m;
  }
}
