x = list(input().split())
arr = []
for i in range(len(x)):
    if x[i] == '+':
        a = arr.pop()
        b = arr.pop()
        arr.append(a+b)
    elif x[i] == '-':
        b = arr.pop()
        a = arr.pop()
        arr.append(a-b)
    elif x[i] == '*':
        a = arr.pop()
        b = arr.pop()
        arr.append(a*b)
    else:
        arr.append(int(x[i]))
print(arr[-1]) x = list(input().split()) x list(input().split()) list input().split() ().split () input split arr = [] arr [] for i in range(len(x)):
    if x[i] == '+':
        a = arr.pop()
        b = arr.pop()
        arr.append(a+b)
    elif x[i] == '-':
        b = arr.pop()
        a = arr.pop()
        arr.append(a-b)
    elif x[i] == '*':
        a = arr.pop()
        b = arr.pop()
        arr.append(a*b)
    else:
        arr.append(int(x[i])) i range(len(x)) range len(x) len x if x[i] == '+':
        a = arr.pop()
        b = arr.pop()
        arr.append(a+b)
    elif x[i] == '-':
        b = arr.pop()
        a = arr.pop()
        arr.append(a-b)
    elif x[i] == '*':
        a = arr.pop()
        b = arr.pop()
        arr.append(a*b)
    else:
        arr.append(int(x[i])) x[i] == '+' x[i] x i '+' a = arr.pop() a arr.pop() arr.pop arr pop b = arr.pop() b arr.pop() arr.pop arr pop arr.append(a+b) arr.append arr append a+b a b elif x[i] == '-':
        b = arr.pop()
        a = arr.pop()
        arr.append(a-b)
     x[i] == '-' x[i] x i '-' b = arr.pop() b arr.pop() arr.pop arr pop a = arr.pop() a arr.pop() arr.pop arr pop arr.append(a-b) arr.append arr append a-b a b elif x[i] == '*':
        a = arr.pop()
        b = arr.pop()
        arr.append(a*b)
     x[i] == '*' x[i] x i '*' a = arr.pop() a arr.pop() arr.pop arr pop b = arr.pop() b arr.pop() arr.pop arr pop arr.append(a*b) arr.append arr append a*b a b arr.append(int(x[i])) arr.append arr append int(x[i]) int x[i] x i print(arr[-1]) print arr[-1] arr -1 x = list(input().split()) list(input().split()) x b = arr.pop() arr.pop() b arr = [] [] arr b = arr.pop() arr.pop() b a = arr.pop() arr.pop() a a = arr.pop() arr.pop() a b = arr.pop() arr.pop() b a = arr.pop() arr.pop() a
x = list(input().split())
arr = []
for i in range(len(x)):
    if x[i] == '+':
        a = arr.pop()
        b = arr.pop()
        arr.append(a+b)
    elif x[i] == '-':
        b = arr.pop()
        a = arr.pop()
        arr.append(a-b)
    elif x[i] == '*':
        a = arr.pop()
        b = arr.pop()
        arr.append(a*b)
    else:
        arr.append(int(x[i]))
print(arr[-1])