Leaky Jaiden
Jaiden has decided to leave the corporate world behind, and has just started his very own boutique high frequency trading company. Things have been running smoothly and profits are being turned, but unfortunately Jaiden's trading algorithm is leaking memory, meaning that it'll eventually crash if it isn't fixed. Lucky for him, if he has enough RAM, he doesn't actually need to debug and fix the memory leak as he can reboot outside of market hours.
After profiling the memory usage of the program, Jaiden finds that the number of bytes of memory leaked at is equal to the number of
's in the binary representation of
. For example, on a trading day that lasts 3 seconds, at
,
byte of memory is leaked, at
,
byte, and at
,
bytes, for a total of
bytes of memory leaked.
Since RAM is rather expensive right now, Jaiden cannot buy any. As such, he'd like to find out how long his program will stay alive before having to restart given the RAM he currently has.
Input
The first and only line consists of a single integer
, the number of bytes of RAM that Jaiden has.
Output
Output a single integer - the number of seconds that the program will stay alive. It is guaranteed that this answer will fit in a 64-bit integer.
Examples
Input
4
Output
3
At ,
byte of memory is leaked.
At , another byte.
At ,
more bytes.
All bytes of RAM have been used, and as such the program will last
seconds.
Input 2
10
Output 2
6
At ,
byte of memory is leaked.
At ,
byte.
At ,
bytes.
At ,
byte.
At ,
bytes.
At ,
bytes.
At this point, a total of bytes of memory have been leaked.
At ,
bytes of memory would be leaked, which would push our total to
bytes of memory leaked, crashing the program. As such, the program will last
seconds.
Comments