Binary Palindromes#9577

Binary Palindromes

1 second
64 megabytes
Medium

Your task is to determine the smallest binary palindrome that is greater than or equal to a given number .A binary palindrome is a number that appears the same when read from left to right and right to left in the binary numeral system. For example, the numbers , , , and are binary palindromes, whereas , , and are not.

Input

The first line contains the integer .

Output

Output a single line with the smallest binary palindrome that is greater than or equal to .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading

Scoring

  • 40% of the test cases will have n \le 10^5

  • 60% of the test cases will have n \le 10^{18}