Base-2 Palindromes

No attempts yetTime limit1sMemory limit256 MB

Problem

A positive integer NN is a base-bb palindrome when the base-bb representation of NN reads the same forward and backward. For example, the decimal number 7 is a single digit in every base 8 or larger, so it is a palindrome in all of those bases. It is a palindrome in base 2 (111111) and in base 6 (1111) as well, but not in base 3 (2121), base 4 (1313), base 5 (1212), or base 7 (1010). Written in base 10 and sorted from smallest, the base-2 palindromes begin 1, 3, 5, 7.

Find the MM-th base-2 palindrome and print it in base 10.

Input

The first line contains one positive integer MM written in base 10. (1M500001 \le M \le 50000)

Output

Print the MM-th base-2 palindrome in base 10 on the first line.