#C12643. Evaluate Arithmetic Expression

    ID: 42093 Type: Default 1000ms 256MiB

Evaluate Arithmetic Expression

Evaluate Arithmetic Expression

You are given a string representing a mathematical expression containing non-negative integers and the operators +, -, *, and / (integer division). Your task is to evaluate the expression correctly while respecting the standard operator precedence rules. Multiplication and division have a higher precedence than addition and subtraction. Note that the division operation is defined as $\lfloor \frac{a}{b} \rfloor$, with the division result truncated towards zero.

Examples:

  • 3+5 / 2 evaluates to 5.
  • 3 + 2 * 2 evaluates to 7.
  • 12 + 3 / 3 * 2 evaluates to 14.
  • 100 evaluates to 100.
  • 1 - 1 + 1 evaluates to 1.

Implement a solution that reads the expression from standard input and outputs the computed result to standard output.

inputFormat

The input consists of a single line that contains the mathematical expression as a string. The expression may contain spaces.

outputFormat

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

## sample
3+5
8

</p>