Toggle the bits
Flip every bit of N in its binary form, from the most significant 1 down to the last bit, and print the new number. For example 10 is 1010, which becomes 0101 = 5.
Reported in: Deloitte (memory-based)
Input
One line: N.
Output
The number after flipping.
Constraints
1 ≤ N ≤ 10^18.
Example 1
Input:
10
Output:
5Example 2
Input:
7
Output:
0Hint: Build a mask of all 1s as long as N in binary, then XOR it with N.