A = input().split()
S, top = [0], 0


def push(x):
    global top, S
    top += 1
    if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x


def pop(x):
    global top, S
    top -= 2
    if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2]))


for i in range(len(A)):
    if str(A[i]).isdigit():
        push(int(A[i]))
    else:
        pop(A[i])
print(S[1])
 A = input().split() A input().split() ().split () input split S, top = [0], 0 S [0] 0 top 0 def push(x):
    global top, S
    top += 1
    if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x push global top, S top += 1 top 1 if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x len(S) < top + 1 len(S) len S top + 1 top 1 S.append(x) S.append S append x S[top] = x S[top] S top x x x def pop(x):
    global top, S
    top -= 2
    if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2])) pop global top, S top -= 2 top 2 if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2])) x == "+" x "+" push(int(S[top + 1]) + int(S[top + 2])) push int(S[top + 1]) + int(S[top + 2]) int(S[top + 1]) int S[top + 1] S top + 1 top 1 int(S[top + 2]) int S[top + 2] S top + 2 top 2 elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
     x == "-" x "-" push(int(S[top + 1]) - int(S[top + 2])) push int(S[top + 1]) - int(S[top + 2]) int(S[top + 1]) int S[top + 1] S top + 1 top 1 int(S[top + 2]) int S[top + 2] S top + 2 top 2 elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2])) x == "*" x "*" push(int(S[top + 1]) * int(S[top + 2])) push int(S[top + 1]) * int(S[top + 2]) int(S[top + 1]) int S[top + 1] S top + 1 top 1 int(S[top + 2]) int S[top + 2] S top + 2 top 2 x x for i in range(len(A)):
    if str(A[i]).isdigit():
        push(int(A[i]))
    else:
        pop(A[i]) i range(len(A)) range len(A) len A if str(A[i]).isdigit():
        push(int(A[i]))
    else:
        pop(A[i]) str(A[i]).isdigit() (A[i]).isdigit (A[i]) str A[i] A i isdigit push(int(A[i])) push int(A[i]) int A[i] A i pop(A[i]) pop A[i] A i print(S[1]) print S[1] S 1 def push(x):
    global top, S
    top += 1
    if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x def push(x):
    global top, S
    top += 1
    if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x push def pop(x):
    global top, S
    top -= 2
    if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2])) def pop(x):
    global top, S
    top -= 2
    if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2])) pop top = [0], 0 0 top A = input().split() input().split() A S, top = [0], 0 [0] S
A = input().split()
S, top = [0], 0


def push(x):
    global top, S
    top += 1
    if len(S) < top + 1:
        S.append(x)
    else:
        S[top] = x


def pop(x):
    global top, S
    top -= 2
    if x == "+":
        push(int(S[top + 1]) + int(S[top + 2]))
    elif x == "-":
        push(int(S[top + 1]) - int(S[top + 2]))
    elif x == "*":
        push(int(S[top + 1]) * int(S[top + 2]))


for i in range(len(A)):
    if str(A[i]).isdigit():
        push(int(A[i]))
    else:
        pop(A[i])
print(S[1])

