eolymp
bolt
Try our new interface for solving problems
Problems

Numerical sequence

Numerical sequence

Dima has recently joined the Scientific Research Institute "\textit{Number Sequences}". As the name of this institution, the main focus of his work is to conduct various researches in the field of numerical sequences. Recently the head of the department, where he began work Dima, in addressing one of the problems encountered with a very interesting sequence of numbers \textbf{a_1}, \textbf{a_2}, …, which is defined as follows: the first term \textbf{a_1}\textit{ = }\textbf{0}, and each subsequent number \textbf{a_i} (\textbf{i}\textit{ > }\textbf{1}) is defined as the smallest natural number greater than \textbf{a_\{i-\}_1}, decimal record does not contain figures presented in decimal notation \textbf{a_\{i-\}_1}. Need to write a program, which calculates the value of \textbf{n} the value of \textbf{a_n}. \InputFile One integer \textbf{n} (\textbf{1 }≤ \textbf{n }≤ \textbf{500}). \OutputFile Print a single number \textbf{a_n}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
Output example #1
0
Source 2008 XIX regional school olympiad in informatics, Vologda, Problem А