Problem10050--ABC340 —— C - Divide and Divide

10050: ABC340 —— C - Divide and Divide

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

There is a single integer $N$ written on a blackboard.  
Takahashi will repeat the following series of operations until all integers not less than $2$ are removed from the blackboard:

-   Choose one integer $x$ not less than $2$ written on the blackboard.
-   Erase one occurrence of $x$ from the blackboard. Then, write two new integers $\left \lfloor \dfrac{x}{2} \right\rfloor$ and $\left\lceil \dfrac{x}{2} \right\rceil$ on the blackboard.
-   Takahashi must pay $x$ yen to perform this series of operations.

Here, $\lfloor a \rfloor$ denotes the largest integer not greater than $a$, and $\lceil a \rceil$ denotes the smallest integer not less than $a$.

What is the total amount of money Takahashi will have paid when no more operations can be performed?  
It can be proved that the total amount he will pay is constant regardless of the order in which the operations are performed.

Input

The input is given from Standard Input in the following format:

```
$N$
```

Output

Print the total amount of money Takahashi will have paid, in yen.

Constraints

-   $2 \leq N \leq 10^{17}$

Sample 1 Input

3

Sample 1 Output

5
Here is an example of how Takahashi performs the operations:
  • Initially, there is one 3 written on the blackboard.
  • He chooses 3. He pays 3 yen, erases one 3 from the blackboard, and writes $⌊\frac{3}{2}⌋=1$ and $⌈\frac{3}{2}⌉=2$ on the blackboard.
  • There is one 2 and one 1 written on the blackboard.
  • He chooses 2. He pays 2 yen, erases one 2 from the blackboard, and writes $⌊\frac{2}{2}⌋=1$ and $⌈\frac{2}{2}⌉=1$ on the blackboard.
  • There are three 1s written on the blackboard.
  • Since all integers not less than 2 have been removed from the blackboard, the process is finished.
Takahashi has paid a total of 3+2=5 yen for the entire process, so print 5.

Sample 2 Input

340

Sample 2 Output

2888

Sample 3 Input

100000000000000000

Sample 3 Output

5655884811924144128

Source/Category