#16D8103014C 安藤 陸人
#3_A
x = input().split()
flag = 0
j = -1
y = []
for i in range(len(x)):
    j = len(y) -1
    if x[i] == "+":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b+a)
    elif  x[i] == "-":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b-a)
    elif x[i] == "*":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b*a)
    else:
        y.append(int(x[i]))
print(y[0]) x = input().split() x input().split() ().split () input split flag = 0 flag 0 j = -1 j -1 y = [] y [] for i in range(len(x)):
    j = len(y) -1
    if x[i] == "+":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b+a)
    elif  x[i] == "-":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b-a)
    elif x[i] == "*":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b*a)
    else:
        y.append(int(x[i])) i range(len(x)) range len(x) len x j = len(y) -1 j len(y) -1 len(y) len y 1 if x[i] == "+":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b+a)
    elif  x[i] == "-":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b-a)
    elif x[i] == "*":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b*a)
    else:
        y.append(int(x[i])) x[i] == "+" x[i] x i "+" a = y.pop(j) a y.pop(j) y.pop y pop j b = y.pop(j-1) b y.pop(j-1) y.pop y pop j-1 j 1 y.append(b+a) y.append y append b+a b a elif  x[i] == "-":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b-a)
     x[i] == "-" x[i] x i "-" a = y.pop(j) a y.pop(j) y.pop y pop j b = y.pop(j-1) b y.pop(j-1) y.pop y pop j-1 j 1 y.append(b-a) y.append y append b-a b a elif x[i] == "*":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b*a)
     x[i] == "*" x[i] x i "*" a = y.pop(j) a y.pop(j) y.pop y pop j b = y.pop(j-1) b y.pop(j-1) y.pop y pop j-1 j 1 y.append(b*a) y.append y append b*a b a y.append(int(x[i])) y.append y append int(x[i]) int x[i] x i print(y[0]) print y[0] y 0 y = [] [] y b = y.pop(j-1) y.pop(j-1) b a = y.pop(j) y.pop(j) a a = y.pop(j) y.pop(j) a x = input().split() input().split() x j = len(y) -1 len(y) -1 j flag = 0 0 flag a = y.pop(j) y.pop(j) a j = -1 -1 j b = y.pop(j-1) y.pop(j-1) b b = y.pop(j-1) y.pop(j-1) b
#16D8103014C 安藤 陸人
#3_A
x = input().split()
flag = 0
j = -1
y = []
for i in range(len(x)):
    j = len(y) -1
    if x[i] == "+":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b+a)
    elif  x[i] == "-":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b-a)
    elif x[i] == "*":
        a = y.pop(j)
        b = y.pop(j-1)
        y.append(b*a)
    else:
        y.append(int(x[i]))
print(y[0])
