S = []

W = raw_input().split()
    
for word in W:
    if word == "+":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s1 + s2)
    elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
    elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
    else:
        S.append(int(word))

print S.pop() S = [] S [] W = raw_input().split() W raw_input().split() ().split () raw_input split for word in W:
    if word == "+":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s1 + s2)
    elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
    elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
    else:
        S.append(int(word)) word W if word == "+":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s1 + s2)
    elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
    elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
    else:
        S.append(int(word)) word == "+" word "+" s1 = S.pop() s1 S.pop() S.pop S pop s2 = S.pop() s2 S.pop() S.pop S pop S.append(s1 + s2) S.append S append s1 + s2 s1 s2 elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
     word == "-" word "-" s1 = S.pop() s1 S.pop() S.pop S pop s2 = S.pop() s2 S.pop() S.pop S pop S.append(s2 - s1) S.append S append s2 - s1 s2 s1 elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
     word == "*" word "*" s1 = S.pop() s1 S.pop() S.pop S pop s2 = S.pop() s2 S.pop() S.pop S pop S.append(s2 * s1) S.append S append s2 * s1 s2 s1 S.append(int(word)) S.append S append int(word) int word print S.pop() S.pop S pop s1 = S.pop() S.pop() s1 s2 = S.pop() S.pop() s2 s1 = S.pop() S.pop() s1 W = raw_input().split() raw_input().split() W s2 = S.pop() S.pop() s2 s1 = S.pop() S.pop() s1 S = [] [] S s2 = S.pop() S.pop() s2
S = []

W = raw_input().split()
    
for word in W:
    if word == "+":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s1 + s2)
    elif word == "-":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 - s1)
    elif word == "*":
        s1 = S.pop()
        s2 = S.pop()
        S.append(s2 * s1)
    else:
        S.append(int(word))

print S.pop()