#include <iostream> #include <cmath> using namespace std; int main() { int n; cin >> n; if (n == 0) cout << 0 << endl; else { n = abs(n); int dp[n + 1]; dp[0] = 0; dp[1] = 1; for(int i=2;i<=n;i++){ if(i % 2 == 0) dp[i] = dp[i / 2] + 1; else dp[i] = min(dp[i-1], dp[(i + 1) / 2] + 1) + 1; } cout << dp[n] << endl; } return 0; }