#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
int main() {
  int a, b, count, result;
  while (~scanf("%d %d", &a, &b)) {
    count = 0;
    while (a < b) {
      if (b % 2 != 0) {
        b++;
        count++;
      } else {
        b = b / 2;
        count++;
      }
    }
    result = a - b;
    cout << result + count << endl;
  }
  return 0;
}
