Maximum minus minimum
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Given a positive integer N, calculate the difference between the maximum and minimum values obtained by permuting the bits of this number, from the least significant bit to the most significant bit. For instance, consider the number 22, which has a binary representation of 10110[2]
. The maximum value from permutations of these bits is 11100[2]
, which equals 28, and the minimum value is 00111[2]
, which equals 7. Therefore, the difference is 21.
Constraints
0 < N ≤ 101^8
.
Input
The first line of the input contains the number N.
Output
Output a single line with the result of the calculation.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 344
Acceptance rate 49%