Binary vs Decimal
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Bruce has recently got a job at NEERC (Numeric Expression Engineering Research Center) facility, which studies and produces many kinds of curious numbers. His first assignment is to perform a study of bindecimal numbers.
A positive integer is called bindecimal if its decimal representation is a suffix of its binary representation; both binary and decimal representations are considered without leading zeros. For example, , thus is a bindecimal number. The numbers and are, evidently, not bindecimal.
First of all, Bruce is going to create a list of bindecimal numbers. Help him find the -th smallest bindecimal number.
Input
The first and the only line contains one integer .
Output
Print one integer — the -th smallest bindecimal number in decimal notation.
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #3
Answer #3
Submissions 1K
Acceptance rate 18%