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