#C14530. Evaluate Mathematical Expression

    ID: 44190 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

You are given a string representing a mathematical expression which consists of non-negative integers, the addition operator +, the multiplication operator *, and parentheses ( ). The expression may also contain spaces. You must evaluate the expression while respecting the operator precedence: multiplication has higher precedence than addition, and parentheses override the normal precedence.

Note: The expression is guaranteed to be valid. Your program should read the expression from stdin and output the resulting integer value to stdout.

Examples:

  • Input: 3+5*2 → Output: 13
  • Input: (2+3)*(4+5) → Output: 45

inputFormat

The input consists of a single line that contains the mathematical expression (a string). The expression may contain digits, spaces, the operators + and *, and parentheses.

outputFormat

Output a single integer: the result of evaluating the expression.

## sample
3+5*2
13

</p>