Problem8737--[CSES Problem Set] Counting Bits

8737: [CSES Problem Set] Counting Bits

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

Description

Your task is to count the number of one bits in the binary representations of integers between 1 and n.

Input

The only input line has an integer n.

Output

Print the number of one bits in the binary representations of integers between 1 and n.

Constraints

$1 \leq n \leq 10^{15}$

Sample 1 Input

7

Sample 1 Output

12
The binary representations of 1…7 are 1, 10, 11, 100, 101, 110, and 111, so there are a total of 12 one bits.

HINT

相同题目:CSES 1146

Source/Category