#P1557. Kruscal的加法

Kruscal的加法

Description

Of course, the new notation is based on the original one. The difference is that the above can be written directly as +++15; similarly, an expression like -15*3 can be written as ---15. After a while, Kruscal was bothered by the countless + and - signs, so he improved the notation again.

For example, +15*3 can also be written as +(3)15, and similarly, -15*3 is equivalent to -(3)15. But as you can see, when the multiplier is small, expressions like +++15 are still convenient, so this form is kept in the new notation.

There is a special note about the expressions: when converting +15*3 to a Kruscal-style expression, you can write it as +++15 or +(3)15, but not as ++(2)15.

The expression 23+15*3-2 can be written in the following forms: 23+++15-2, 23+(3)15-2, +23+++15-2, +23+(3)15-2, +(1)23+(3)15-(1)2. The following forms will not appear: (1)23+++15-2, +23++(2)15-(1)2, 23+++15-2+(0)100, 23-(-3)15-2.

Input Format

One line, a Kruscal-style expression.

Output Format

One line, the result of the computation.

+(1)23+(3)15-(1)2
66

Hint

For 100%100\% of the testdata, the expression length does not exceed 2000.

Translated by ChatGPT 5