#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include using namespace std; using i32 = int_fast32_t; using i64 = int_fast64_t; #define rep(i, n) for (i32 i = 0; i < (i32)(n); i++) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() using P = pair; mapmp; i64 n; void dfs(i64 x,i64 cnt){ if(x != 1 && mp[x] != 0 && mp[x] < cnt){ return; }else if(x == n){ mp[x] = cnt; return ; }else if(x < 1){ return ; }else if(x > 2 * n){ return ; } mp[x] = cnt; dfs(2 * x,cnt + 1); dfs(x - 1,cnt + 1); return ; } main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cin >> n; dfs((i64)(1),(i64)(0)); cout << mp[n] << endl; }