#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, rez = 0;
  cin >> n >> m;
  while (m != n) {
    if (m < n)
      ++m;
    else if (m % 2)
      ++m;
    else
      m /= 2;
    ++rez;
  }
  cout << rez;
}
