Max - Min in the binary numeral system#7457

Max - Min in the binary numeral system

1 секунда
64 мегабајта
Лако

When exploring the binary numeral system, Vasylko devised an exercise to test his understanding. He rearranged the bits of a given number to form both the largest and smallest possible numbers, then calculated the difference between them. However, he is uncertain if his approach is correct.

Assist him by writing a program that, for a given number , computes the difference between the largest and smallest numbers that can be formed by rearranging the bits of . The largest number should have its highest bit in the same position as the highest bit of .

Улаз

The input consists of a single line containing the number (N < 2^{31}).

Излаз

Output a single number, which is the result of Vasylko's exercise.

Примери

Пример 1

Loading
Loading

Напомена

N = 13_{10}, its binary representation is 1101_2. The largest number that can be formed is 1110_2 = 14_{10}, and the smallest is 0111_2 = 7_{10}. 14 - 7 = 7.