P1449 Postfix Expression

Description

A postfix expression is an expression in which parentheses are not used, operators are placed after their two operands, and all computations are performed strictly from left to right in the order in which the operators appear (operator precedence does not need to be considered). In this problem, the operators include only $\texttt{+-*/}$. It is guaranteed that for the $\texttt{/}$ operation the divisor is not 0. In particular, the result of the $\texttt{/}$ operation should be truncated toward 0 (i.e., the same rule as C++ `/`). For example: $\texttt{3*(5-2)+7}$ corresponds to the postfix expression $\texttt{3.5.2.-*7.+@}$. In this expression, `@` is the end marker for the expression. `.` is the end marker for an operand.

Input Format

Input a single line containing a string $s$, denoting the postfix expression.

Output Format

Output a single integer, the value of the expression.

Explanation/Hint

It is guaranteed that $1 \leq |s| \leq 50$, and the absolute value of the answer and of every intermediate value during computation does not exceed $10^9$. Translated by ChatGPT 5