from collections import deque as D

line, stack = D(input().split()), D()

while line:

    hoge = line.popleft()

    if hoge.isdigit():

        stack.append(hoge)

    else:

        a, b = int(stack.pop()),int(stack.pop())

        if hoge =="*":

            stack.append(a*b)

        elif hoge == "+":

            stack.append(a+b)

        elif hoge == "-":

            stack.append(b-a)

        else:

            stack.append(b//a)

print((stack.popleft()))

s = list(input().split())

a = []

for x in s:

    if  x in  ['+', '-', '*']:

        c, b = str(a.pop()), str(a.pop())

        b+= x+c

        a+=[int(eval(b))]

    else:

        a+= [int(x)]

print((a.pop()))



        

        

from collections import deque as D

line, stack = D(input().split()), D()
while line:
    hoge = line.popleft()
    if hoge.isdigit():
        stack.append(hoge)
    else:
        a, b = int(stack.pop()), int(stack.pop())
        if hoge == "*":
            stack.append(a * b)
        elif hoge == "+":
            stack.append(a + b)
        elif hoge == "-":
            stack.append(b - a)
        else:
            stack.append(b // a)
print((stack.popleft()))

s = list(input().split())
a = []
for x in s:
    if x in ["+", "-", "*"]:
        c, b = str(a.pop()), str(a.pop())
        b += x + c
        a += [int(eval(b))]
    else:
        a += [int(x)]
print((a.pop()))

-from collections import deque as D - -line, stack = D(input().split()), D() -while line: -    hoge = line.popleft() -    if hoge.isdigit(): -        stack.append(hoge) +s = list(input().split()) +a = [] +for x in s: +    if x in ["+", "-", "*"]: +        c, b = str(a.pop()), str(a.pop()) +        b += x + c +        a += [int(eval(b))] -        a, b = int(stack.pop()), int(stack.pop()) -        if hoge == "*": -            stack.append(a * b) -        elif hoge == "+": -            stack.append(a + b) -        elif hoge == "-": -            stack.append(b - a) -        else: -            stack.append(b // a) -print((stack.popleft())) +        a += [int(x)] +print((a.pop()))