#K45432. Evaluate Mathematical Expression

    ID: 27752 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

You are given a string s representing a mathematical expression. The expression consists of non-negative integers and the binary operators \(+, -, \times, \div\). You are required to evaluate the expression according to the standard operator precedence: multiplication and division are evaluated before addition and subtraction.

Note that division \(\div\) should truncate towards zero. In other words, the result of \(a \div b\) is the integer part obtained by discarding the fractional part.

For example:

  • Input: 3+2*2 → Output: 7
  • Input: 14-3/2 → Output: 13

Your task is to read the expression from the standard input, evaluate it, and print the integer result to the standard output.

inputFormat

The input consists of a single line that contains a string s representing the mathematical expression. The expression includes non-negative integers and the operators +, -, *, /. Whitespaces might appear anywhere in the expression and should be ignored.

Example: 3+2*2

outputFormat

Output a single integer which is the evaluated result of the expression.

Example: For input 3+2*2, the output should be 7.

## sample
3+2+2
7