#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t, n, m, res;
  res = 0;
  cin >> n >> m;
  while (m > n) {
    if (m % 2)
      m++;
    else
      m /= 2;
    res++;
  }
  cout << res + n - m;
  return 0;
}
