#K5856. Arithmetic Expression Evaluation

    ID: 30669 Type: Default 1000ms 256MiB

Arithmetic Expression Evaluation

Arithmetic Expression Evaluation

You are given a mathematical expression containing positive integers and the operators \(+, -, *\). The expression follows standard operator precedence where multiplication is computed before addition and subtraction. The tokens in the expression are separated by spaces. Your task is to evaluate the given expression and output the result.

Note: The operators and operands are separated by a single space. You should carefully follow the operator precedence rules.

Examples:

  • Input: "3 + 5 * 2" → Output: 13
  • Input: "10 - 2 * 5" → Output: 0
  • Input: "7 * 4 - 3 + 2" → Output: 27

inputFormat

The input is provided via standard input (stdin) as a single line containing the arithmetic expression. The expression consists of positive integers and the operators +, -, and *, each separated by a space.

For example:

3 + 5 * 2

outputFormat

Print the evaluated result of the arithmetic expression as an integer to standard output (stdout).

## sample
3 + 5 * 2
13