#include <bits/stdc++.h>
using namespace std;
int xx[4] = {0, 0, 1, -1};
int yy[4] = {-1, 1, 0, 0};
long long arr[100000];
long long tree[100001];
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  if (n >= m)
    cout << n - m << endl;
  else {
    long long res = 0;
    if (m % 2 != 0) {
      m++;
      res++;
    }
    while (m > n) {
      if (ceil(m / 2.0) != floor(m / 2.0)) res++;
      m = ceil(m / 2.0);
      res++;
    }
    cout << n - m + res << endl;
  }
}
