#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  int dfs(int x, int y) {
    if (x >= y) return x - y;
    if (y % 2 == 1) return 1 + dfs(x, y + 1);
    if (y % 2 == 0) return 1 + dfs(x, y / 2);
  }
  int brokenCalc(int X, int Y) { return dfs(X, Y); }
};
int main() {
  Solution s;
  int n, m;
  cin >> n >> m;
  cout << s.brokenCalc(n, m) << endl;
}
