E - Lucky Numbers on MOG

Languages: C, C++, Java, JavaScript, Tiger, Python, Haskell, Pascal, C#
Time & Memory limits: (details)

Digits $4$ and $7$ are lucky, while all others are unlucky. An integer is lucky if it contains only lucky digits in decimal notation. We would like to know the $K$-th lucky positive integer.

Input

The first and only line of input contains a positive integer $K$ $(1 \leq K \leq 10^9)$.

Output

The first and only line of output must contain the $K$-th lucky positive integer.

Sample test(s)

Input
1
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
4
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
2
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
7
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
3
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
44
--- Showing first 30 lines (click "Copy" to get full content) ---