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