#include using namespace std; int a, b; const int N = 10010; bool st[N]; typedef pair PII; void bfs() { queue q; // q.first 当前是哪个数 q.second 从出发点到q.first走了几步 q.push({a, 0}); st[a] = true; while (q.size()) { auto t = q.front(); q.pop(); int u = t.first; int d = t.second; if (u == b) { cout << d << endl; exit(0); } if (!st[u + 1]) q.push({u + 1, d + 1}); if (!st[u * 2]) q.push({u * 2, d + 1}); } } int main() { cin >> a >> b; bfs(); return 0; }