Reverse the Binary Digits

No attempts yetTime limit1sMemory limit256 MB

Problem

Heeyeon moved to Sweden and goes to school there. She finished first grade in China, and the two countries teach completely different curricula. She likes math, but today's lesson is dull. While the teacher explains subtraction at the board, her mind wanders. What number do you get if you write a number on the board in binary and then reverse its digits? After class she plans to go home and write a program that does it.

Write that program for her. For example, 13 in binary is 1101, and reversing the digits gives 1011. Read back in decimal, that is 11.

Input

The first line contains an integer NN. (1N1091 \le N \le 10^9)

Output

Write NN in binary, reverse its digits, and print the value of the reversed string read back in decimal on the first line.

The binary form of NN carries no leading zeros. Zeros that end up in front after the reversal are simply ignored when the string is read as a number.