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