#include <bits/stdc++.h>   using namespace std;   const int N = 20 * 1000 + 200;   const int INF = 1000 * 1000 * 1000;   int d[N];   int n, m;   inline void read() { scanf( %d %d , &n, &m); }   inline void solve() {     for (int i = 0; i < N; i++) d[i] = INF;     queue<int> q;     q.push(n);     d[n] = 0;     while (!q.empty()) {       int v = q.front();       q.pop();       if (v * 2 <= 20 * 1000 && d[v * 2] == INF) {         q.push(v * 2);         d[v * 2] = d[v] + 1;       }       if (v - 1 > 0 && d[v - 1] == INF) {         q.push(v - 1);         d[v - 1] = d[v] + 1;       }     }     cout << d[m];   }   int main() {     read();     solve();     return 0;   }   