import sys
str = ""
for line in sys.stdin:
	str = line

numbers = str.split()

answer = 0
stackList = []

for number in numbers :

    if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
    elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
    else :
        stackList.append(number)

print(answer)
 import sys sys str = "" str "" for line in sys.stdin:
	str = line line sys.stdin sys stdin str = line str line numbers = str.split() numbers str.split() str.split str split answer = 0 answer 0 stackList = [] stackList [] for number in numbers :

    if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
    elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
    else :
        stackList.append(number) number numbers if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
    elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
    else :
        stackList.append(number) number == '+' number '+' answer = int(stackList.pop()) + int(stackList.pop()) answer int(stackList.pop()) + int(stackList.pop()) int(stackList.pop()) int stackList.pop() stackList.pop stackList pop int(stackList.pop()) int stackList.pop() stackList.pop stackList pop stackList.append(answer) stackList.append stackList append answer elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
     number == '-' number '-' x = int(stackList.pop()) x int(stackList.pop()) int stackList.pop() stackList.pop stackList pop y = int(stackList.pop()) y int(stackList.pop()) int stackList.pop() stackList.pop stackList pop answer = y - x answer y - x y x stackList.append(answer) stackList.append stackList append answer elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
     number == '*' number '*' answer = int(stackList.pop()) * int(stackList.pop()) answer int(stackList.pop()) * int(stackList.pop()) int(stackList.pop()) int stackList.pop() stackList.pop stackList pop int(stackList.pop()) int stackList.pop() stackList.pop stackList pop stackList.append(answer) stackList.append stackList append answer stackList.append(number) stackList.append stackList append number print(answer) print answer answer = int(stackList.pop()) + int(stackList.pop()) int(stackList.pop()) + int(stackList.pop()) answer str = line line str answer = int(stackList.pop()) * int(stackList.pop()) int(stackList.pop()) * int(stackList.pop()) answer stackList = [] [] stackList answer = 0 0 answer numbers = str.split() str.split() numbers x = int(stackList.pop()) int(stackList.pop()) x answer = y - x y - x answer str = "" "" str y = int(stackList.pop()) int(stackList.pop()) y
import sys
str = ""
for line in sys.stdin:
	str = line

numbers = str.split()

answer = 0
stackList = []

for number in numbers :

    if number == '+' :
        answer = int(stackList.pop()) + int(stackList.pop())
        stackList.append(answer)
    elif number == '-' :
        x = int(stackList.pop())
        y = int(stackList.pop())
        answer = y - x
        stackList.append(answer)
    elif number == '*' :
        answer = int(stackList.pop()) * int(stackList.pop())
        stackList.append(answer)
    else :
        stackList.append(number)

print(answer)

