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