#C5335. Evaluating Mathematical Expressions

    ID: 48973 Type: Default 1000ms 256MiB

Evaluating Mathematical Expressions

Evaluating Mathematical Expressions

Problem Statement:

You are given a single expression in infix notation that consists of non-negative integers and the operators +, -, *, / along with parentheses ( ) for controlling the order of operations. Your task is to evaluate the expression and output the resulting integer. The operators follow conventional precedence rules: multiplication and division have a higher precedence than addition and subtraction. In the case of division, perform integer division that truncates toward zero.

Note: The expression is guaranteed to be well-formed. For division, you are essentially computing \(\text{trunc}(a/b)\), where the quotient is truncated towards zero. For example, 10/(5-3) evaluates to 5.

inputFormat

Input is provided via standard input (stdin). It consists of a single line containing a valid mathematical expression. The expression does not contain extraneous spaces (except those that are part of multi-digit numbers).

outputFormat

Output the evaluated result as a single integer to standard output (stdout).

## sample
1+1
2