# coding: utf-8
# Here your code !
import functools
N = input().split()
stack=[]

for i in N:
    if i.isdigit():
        stack.append(int(i))
        
    else:
        key=0
        if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2)
print(stack[0]) import functools functools N = input().split() N input().split() ().split () input split stack=[] stack [] for i in N:
    if i.isdigit():
        stack.append(int(i))
        
    else:
        key=0
        if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2) i N if i.isdigit():
        stack.append(int(i))
        
    else:
        key=0
        if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2) i.isdigit() i.isdigit i isdigit stack.append(int(i)) stack.append stack append int(i) int i key=0 key 0 if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2) i=="+" i "+" p2=stack.pop() p2 stack.pop() stack.pop stack pop p1=stack.pop() p1 stack.pop() stack.pop stack pop stack.append(p1+p2) stack.append stack append p1+p2 p1 p2 elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
         i=="-" i "-" p2=stack.pop() p2 stack.pop() stack.pop stack pop p1=stack.pop() p1 stack.pop() stack.pop stack pop stack.append(p1-p2) stack.append stack append p1-p2 p1 p2 elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2) i=="*" i "*" p2=stack.pop() p2 stack.pop() stack.pop stack pop p1=stack.pop() p1 stack.pop() stack.pop stack pop stack.append(p1*p2) stack.append stack append p1*p2 p1 p2 print(stack[0]) print stack[0] stack 0 p2=stack.pop() stack.pop() p2 p1=stack.pop() stack.pop() p1 p1=stack.pop() stack.pop() p1 key=0 0 key stack=[] [] stack N = input().split() input().split() N p1=stack.pop() stack.pop() p1 p2=stack.pop() stack.pop() p2 p2=stack.pop() stack.pop() p2
# coding: utf-8
# Here your code !
import functools
N = input().split()
stack=[]

for i in N:
    if i.isdigit():
        stack.append(int(i))
        
    else:
        key=0
        if i=="+":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1+p2)
        elif i=="-":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1-p2)
        elif i=="*":
            p2=stack.pop()
            p1=stack.pop()
            stack.append(p1*p2)
print(stack[0])