eolymp
bolt
Try our new interface for solving problems

Snake

\includegraphics{https://static.e-olymp.com/content/71/71e50bb2eb3d10a00addde6ed5b7a19bb7f175d7.jpg} Boy Vasya the lesson of mathematics, instead of listening to the teacher, drawing numbers in a notebook in the cell. Do not just draw, but in a certain way. First, he put in a cage number \textbf{1}. Then the right of it drew the number \textbf{2}. Then the bottom of the number \textbf{2} wrote the number \textbf{3}. He then moved to the cell to the right and continued engaging lesson on moving up the column, while the number in this column does not become higher than the highest number in the previous column. He then proceeded to the cage to the right and again continued the drawing of numbers starting with \textbf{7}, but already down until it drew a number that turned out to be one cell below the lowest number in the previous column. And so on. Vasya not like numbers ending in zero, and let them in drawing snakes. First of his six-filled columns, we have copied from his notebooks and brought here in the picture. Since Vasya very curious, he very much wants to know what kind of numbers he will have to stand in the \textbf{N}-th column in the row, which is the number \textbf{1}. The first \textbf{6} of those numbers in this row can be seen in the figure: \textbf{1}, \textbf{2}, \textbf{5}, \textbf{8}, \textbf{14}, \textbf{19}. Write a program that helps Vasya. \InputFile We introduce a single number \textbf{N} (\textbf{1}  ≤  \textbf{N}\textit{ } ≤  \textbf{10^6}) -- the column number. \OutputFile Output \textbf{N}-th line, where is the number \textbf{1}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5
Output example #1
14