## Problem E. Expression with period ≡

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

### 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:

• expression ::= 0|1|2|3|4|5|6|7|8|9|x
• expression ::= expression+expression
• expression ::= expression*expression
• expression ::= sin(expression)

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 106. 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.022s 0.007s 9