#ifdef LOCAL #include #else #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") #include #define debug(...) (static_cast(0)) #define postprocess() (static_cast(0)) #endif // #include "atcoder/dsu.hpp" // #include "atcoder/modint.hpp" // using mint = atcoder::modint998244353; // using mint = atcoder::modint1000000007; using namespace std; using ll = long long; using ld = long double; ll rec(ll N) { if (N == 1) { return 0; } if (N % 2 == 1) { return 1 + rec(N + 1); } for (int i = 1; i <= 30; i++) { if (N & (1 << i)) { return 1 + rec(N >> i); } } assert(false); } void solve([[maybe_unused]] int test) { ll N; cin >> N; cout << rec(N) << endl; } int main() { ios::sync_with_stdio(false), cin.tie(nullptr); int t = 1; // cin >> t; for (int _t = 1; _t <= t; _t++) solve(_t); postprocess(); }