Problem E. Expression with period

Author:A. Klenin   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  

Statement

An expression for a function is composed of single-digit numbers, variable x, signs  +  and  * , and zero or one calls to function sin. More formally:

Function f(x) has period p if f(x + p) = f(x) for all x.

Your program must, given an expression with no more than one call to sin, determine the minimal period of a function.

Input file format

The input file contains a single string — expression.

Output file format

Output file must contain single a floating point number — period with relative error not greater than 10 − 6. If a function is constant or aperiodic, output number 0.

Constraints

Expression length is between 1 and 25 characters. There are no spaces in expression.

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
sin(x)+x
0
2
5*6*sin(2*x+5+x*7+x)+1
0.62831853
3
sin(x*0)
0

0.088s 0.011s 13