#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const int M = 1e9;
vector<pair<int, int> > v[N];
bool vis[N];
int tot;
int main() {
  int n, m, cnt = 0;
  cin >> n >> m;
  if (m <= n) {
    cout << n - m;
    return 0;
  }
  while (n < m) {
    if (m % 2 == 1) {
      m++;
      ++cnt;
    }
    m = m / 2;
    ++cnt;
  }
  cnt += n - m;
  cout << cnt;
  return 0;
}
