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