Problem E
Series of Pi
Input: standard input
Output: standard output
Time Limit: 3 seconds

 

We all know the importance of pi or π in different fields of mathematics. Pi is a constant defined as the ratio of the circumference and diameter of the same circle. Mathematicians have always remained interested in finding the value of pi as accurately as they can. For this purpose many series of pi has been invented. The proof or derivation methods of some of these series are not at all difficult. For example from the relation ship  , we can derive the formula:

 

The problem with this formula is that it converges very slowly. For example to find the value of pi correctly up to five digits after the decimal point you have to add the first 130658 term of the series above, which is not an healthy option at all. Also due to the precision limitation of floating-point numbers, a series whose terms change sign alternately succumbs to precision error severely. A better series can be developed from the relationship . First few terms of the series will be something like, . This series converges very fast. For example to find the value of pi correctly up to five digits after the decimal point you have to add only first 7th term of this series. In practical field it is impossible to sum a series up to infinite terms so generally a series is summed until the term to be added goes below a certain value. This certain value can be called the threshold value. Given the threshold value your job is to find out how many terms of the second series you need to add before the term reaches below the threshold value.

 

Input

The input file contains less than 1000 lines of input. Each line contains an integer n (1<=n<=600000). Input is terminated by a case where the value of n is negative. This line should not be processed.

 

Output

For each line of input you should produce one line of output. This line contains an integer which indicates how many terms are added before a term reaches below the value 10-n.

 

Sample Input                            Output for Sample Input

1

5

100000

-1

2

7

166084

 


Problem setter: Shahriar Manzoor. EPS

Special Thanks: Derek Kisman, EPS