Question
Happy Numbers
A number is a special number if its digits only consist of 0, 1, 2, 3, 4, or 5. Given a number N we have to find Nth Happy Number.
Input
There is a single line of input taking an integer representing N.

Constraints:
1 ≤ N ≤ 106
Output
Print a single integer representing the value Nth happy value.
Example
Input:
6
Output:
5
Explanation:
The first 6 numbers are ( 0, 1, 2, 3, 4, 5 )

Input:
7
Output:
10
Explanation:
The first 7 numbers are ( 0, 1, 2, 3, 4, 5, 10 )

Online