#include <bits/stdc++.h>
using namespace std;
vector<int> ar[20001];
int vis[20001];
int dist[20001];
void BFS(int src) {
  queue<int> q;
  q.push(src);
  vis[src] = 1;
  dist[src] = 0;
  while (!q.empty()) {
    int curr = q.front();
    q.pop();
    for (int i = 0; i < ar[curr].size(); i++) {
      int child = ar[curr][i];
      if (vis[child] == 0) {
        q.push(child);
        dist[child] = dist[curr] + 1;
        vis[child] = 1;
      }
    }
  }
}
int main() {
  for (int i = 1; i <= 10000; i++) {
    int a = i - 1;
    int b = 2 * i;
    ar[i].push_back(a);
    ar[i].push_back(b);
  }
  int n, m;
  cin >> n >> m;
  BFS(n);
  cout << dist[m];
  return 0;
}
