#include #include #include typedef long long ll; using namespace std; ll ans = 0, Max = 0, n; void search(ll x) { ll lc = x, rc = x, dep = 0; while(lc * 2 <= n) lc *= 2, dep++; while(rc * 2 + 1 <= n) rc = rc * 2 + 1; if(lc <= rc) Max = max(Max, dep); else { search(x * 2); search(x * 2 + 1); ans++; } } int main() { while(~scanf("%I64d", &n)) { ans = 0; Max = 0; search(1); printf("%I64d\n", ans + Max + 1); } return 0; }