Snake#422

Snake

1 second
64 megabytes
Easy

Boy Vasylko, instead of listening to the mathematics lesson, drew numbers in a notebook, filling the cells in a special way. First, he wrote the number in a cell. Then, to its right, he wrote the number . Then, below , he wrote . Next, he moved to the cell to the right and continued, moving up the column, writing numbers until the number in this column became greater than the topmost number in the previous column. Then, he again moved to the cell to the right and continued writing numbers, this time starting from and moving downward until he wrote a number one cell below the lowest number in the previous column. Vasylko did not like numbers ending in zero and skipped them while drawing his "snake". We have copied the first six filled columns from his notebook and shown them in the figure. Vasylko is very curious and wants to know what number stands in the -th column in the row containing the number . The first such numbers in this row are visible in the figure: , , , , , .

Write a program to help Vasylko.

Input

A single number (1 \leq N \leq 10^6) is given — the number of the column.

Output

Output the number in the -th column in the row where appears.

Examples

Example 1

Loading
Loading