Under construction

Still being built. Things may change

Pascal's Triangle

Time limit2sMemory limit1024 MB

Summary
Count how many entries in row n of Pascal's triangle are odd, where n can be as large as 2 billion.
Level

Easy3 of 10

Topics
Math, Bit manipulation, Number theory, Combinatorics
Solved
No attempts yet

Problem

Pascal's triangle is an infinite triangle of numbers that looks like this:

1
11
121
1331
14641
15101051
1615201561
172135352171
...........................

The rows of Pascal's triangle are numbered from zero, and the numbers in each row are also numbered from zero. Row zero contains a single number, one, and each subsequent row contains one more number than the previous row. The zeroth and last numbers of each row are one, and each of the others equals the sum of the two numbers above it in the previous row.

Thus row ii contains i+1i + 1 numbers. If the jj-th element of row ii is denoted ai,ja_{i,j}, then ai,j=ai−1,j−1+ai−1,ja_{i,j} = a_{i - 1,j - 1} + a_{i-1,j}. This equality also holds for the end elements if the missing elements of the previous row (elements numbered −1-1 and ii) are taken to be zero.

Kolya wants to know how many odd numbers there are in row nn of Pascal's triangle. He started drawing the triangle, but it soon stopped fitting on the sheet of paper. So Kolya decided to do this with a computer. Help him.

Input

The input file contains the number nn (0≤n≤2⋅1090 \le n \le 2 \cdot 10^9).

Output

The output file must contain one number: the count of odd numbers in row nn of Pascal's triangle.

Examples3

  1. Example 1

    Input
    0
    
    Expected output
    1
    
  2. Example 2

    Input
    5
    
    Expected output
    4
    
  3. Example 3

    Input
    7
    
    Expected output
    8