Search for a command to run...
Joseph is studying digital logic for his next semester. He received a problem where he must work with binary representation of numbers.
You are given a positive integer N.
Steps to solve the problem:
Convert the decimal number N to its binary representation.
Toggle all the bits of the binary number (change 1 → 0 and 0 → 1), including the most significant bit (MSB).
Convert the new binary number back to decimal.
Print the resulting integer.
1≤N≤1001 \le N \le 1001≤N≤100
A single integer N.
An integer representing the decimal value after toggling all bits of the binary representation.
Input
10Output
5Explanation
Binary representation of 10 → 1010
Toggle all bits → 0101
Decimal value of 0101 → 5
So the output is 5.
Example 1
105Example 2
61Example 3
501310
5