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