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