Colossal! — exclaimed the hunchback. — Programmer! We need a programmer.
Arkady and Boris Strugatsky, Monday starts on Saturday
Studying the book "Equations of Mathematical Magic" Roman Oira-Oira and Cristobal Junta discovered an interesting equation: a−(a⊕x)−x=0 for a given a, where ⊕ stands for bitwise exclusive OR (XOR) of two numbers (this operation is denoted as ^ or xor in many modern programming languages). Since this equation was intended to be solved on the Aldan-3 machine, all calculations were performed on non-negative integers modulo 2
32. Oira-Oira quickly found x, which is a solution, but Cristobal Junta found Oira-Oira's result not interesting enough, so he asked a colleague how many solutions there are to this equation. Since all calculations are done modulo 2
32, Cristobal Junto is interested in the number of solutions x such that 0 ≤ x≤ 2
32. Such a task turned out to be too difficult for Oira-Oira, so he turned to you for help.
Input
The first line contains a single integer a (0 ≤ a ≤ 2
32−1).
Imprint
Print a single integer — the number of non-negative solutions of the equation.
Note
Let's define the bitwise OR (XOR) operation. Let two non-negative integers x and y be given, consider their binary representations (possibly with leading zeros): x
k...x
2x
1x
0 and y
k...y
2y
1y
0 . Here x
i is the i-th bit of x and y
i is the i-th bit of y. Let r=x⊕y — the result of an XOR operation on the numbers x and y. Then the binary representation of r is r
k...r
2r
1r
0, where:
\(r_i = \begin{cases} 1, & \quad \text{if } x_i \neq y_i \\ 0 , & \quad \text{if } x_i = y_i \end{cases} \)
In the first example, the solutions to the equation are 0 and 2147483648=2
31, because 0−(0⊕0)−0=0−0−0=0 and 0−(0⊕ 2147483648)− 2147483648=−4294967296=−2
32=0 modulo 2
32.
In the second example, the solutions to the equation are 0, 2, 2147483648=2
31 and 2147483650=2
31+2.
In the third example, the solutions are all x for which 0 ≤ x≤ 2
32.
Examples
# |
Input |
Output |
1 |
0 |
2 |
2 |
2 |
4 |
3 |
4294967295 |
4294967296 |