Limits 1s, 512 MB

Read an integer variable, and determine the smallest positive integer that has the same number of 1\texttt{1}s in its bit representation as the number you read.

The following numbers all have the same number of 1\texttt{1}s in their bit representation: 7 (111\texttt{111}), 13 (1101\texttt{1101}), 37 (100101\texttt{100101}), etc. And among all such positive integers, 7 is the smallest number that has 3 1\texttt{1}s in its bit representation.

Input

The input will contain an integer AA (0A<10000000 \le A < 1000000).

Output

Print the smallest positive integer that has the same number of 1\texttt{1}s in its bit representation as AA.

Sample

InputOutput
37
7

Submit

Login to submit.

Contributors

Statistics

94% Solution Ratio
rezaulhsagarEarliest, Jan '19
rezaulhsagarFastest, 0.0s
Cloud_Lightest, 0 B
n4o847Shortest, 28B
Toph uses cookies. By continuing you agree to our Cookie Policy.