#include <bits/stdc++.h>
using namespace std;
int dp[10001] = {0};
int cal(long long int n, long long int m) {
  if (n >= m) return (n - m);
  if (dp[m] != 0)
    return dp[m];
  else {
    if (m & 1) {
      dp[m] = 1 + cal(n, m + 1);
    } else {
      dp[m] = 1 + cal(n, m / 2);
    }
  }
  return dp[m];
}
int main() {
  long long int m, n, cnt = 0;
  cin >> n >> m;
  cnt = cal(n, m);
  cout << cnt << '\n';
}
