LogiQuest

195. Evaluate Postfix Expression

MediumStack

Evaluate a postfix (reverse Polish) expression with integers and the operators + − * /. Division truncates toward zero.

Input format

A single line of space-separated tokens.

Output format

The value.

Example 1

Input

2 1 + 3 *

Output

9

Example 2

Input

4 13 5 / +

Output

6

Constraints

The expression is valid; |values| ≤ 10⁹

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…