#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, count = 0;
  cin >> n >> m;
  while (m != n) {
    if (m < n) {
      count += (n - m);
      break;
    }
    if (m & 1)
      m++;
    else
      m /= 2;
    count++;
  }
  cout << count;
  return 0;
}
