#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { long long N; cin >> N; long long n = N; long long a = 0; while ( n%2 == 0 ) { n /= 2; a++; } long long ans = 0; long long x = 1; while ( x < n ) { x *= 2; ans++; } ans += x-n; ans += a; cout << ans << endl; return 0; }