Олимпиадный тренинг

Задача 38513. Equations of Mathematical Magic


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 232. 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 232, Cristobal Junto is interested in the number of solutions x such that 0 ≤ x≤ 232. 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 ≤ 232−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): xk...x2x1x0 and yk...y2y1y0 . Here xi is the i-th bit of x and yi 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 rk...r2r1r0, 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=231, because 0−(0⊕0)−0=0−0−0=0 and 0−(0⊕ 2147483648)− 2147483648=−4294967296=−232=0 modulo 232.

In the second example, the solutions to the equation are 0, 2, 2147483648=231 and 2147483650=231+2.

In the third example, the solutions are all x for which 0 ≤ x≤ 232.
 
Examples
# Input Output
1 0 2
2 2 4
3 4294967295 4294967296