import sys


Stack = []
MAX = 1000

def push(x):
    #if isFull():
    #    print "ERROR!"
    #    sys.exit()
    Stack.append(x)

def pop():
    #if isEmpty():
    #    print "ERROR!"
    #    sys.exit()
    Stack.pop(-1)

def cul(exp):
    for v in exp:
        if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

    return Stack[0]

if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans import sys sys Stack = [] Stack [] MAX = 1000 MAX 1000 def push(x):
    #if isFull():
    #    print "ERROR!"
    #    sys.exit()
    Stack.append(x) push Stack.append(x) Stack.append Stack append x x x def pop():
    #if isEmpty():
    #    print "ERROR!"
    #    sys.exit()
    Stack.pop(-1) pop Stack.pop(-1) Stack.pop Stack pop -1 def cul(exp):
    for v in exp:
        if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

    return Stack[0] cul for v in exp:
        if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

     v exp if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

     v == "+" v "+" x = reduce(lambda a,b:int(a)+int(b), Stack[-2:]) x reduce(lambda a,b:int(a)+int(b), Stack[-2:]) reduce lambda a,b:int(a)+int(b) int(a)+int(b) int(a) int a int(b) int b a b Stack[-2:] Stack -2: -2 for i in range(2):
                pop()
             i range(2) range 2 pop() pop push(x) push x elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
         v == "-" v "-" x = reduce(lambda a,b:int(a)-int(b), Stack[-2:]) x reduce(lambda a,b:int(a)-int(b), Stack[-2:]) reduce lambda a,b:int(a)-int(b) int(a)-int(b) int(a) int a int(b) int b a b Stack[-2:] Stack -2: -2 for i in range(2):
                pop()
             i range(2) range 2 pop() pop push(x) push x elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
         v == "*" v "*" x = reduce(lambda a,b:int(a)*int(b), Stack[-2:]) x reduce(lambda a,b:int(a)*int(b), Stack[-2:]) reduce lambda a,b:int(a)*int(b) int(a)*int(b) int(a) int a int(b) int b a b Stack[-2:] Stack -2: -2 for i in range(2):
                pop()
             i range(2) range 2 pop() pop push(x) push x push(v) push v return Stack[0] Stack[0] Stack 0 exp exp if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans __name__ == "__main__" __name__ "__main__" exp = sys.stdin.read().strip().split(" ") exp sys.stdin.read().strip().split(" ") sys.stdin.read().strip().split sys.stdin.read().strip() sys.stdin.read().strip sys.stdin.read() sys.stdin.read sys.stdin sys stdin read strip split " " ans = cul(exp) ans cul(exp) cul exp print def push(x):
    #if isFull():
    #    print "ERROR!"
    #    sys.exit()
    Stack.append(x) def push(x):
    #if isFull():
    #    print "ERROR!"
    #    sys.exit()
    Stack.append(x) push def pop():
    #if isEmpty():
    #    print "ERROR!"
    #    sys.exit()
    Stack.pop(-1) def pop():
    #if isEmpty():
    #    print "ERROR!"
    #    sys.exit()
    Stack.pop(-1) pop MAX = 1000 1000 MAX exp = sys.stdin.read().strip().split(" ") sys.stdin.read().strip().split(" ") exp Stack = [] [] Stack ans = cul(exp) cul(exp) ans def cul(exp):
    for v in exp:
        if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

    return Stack[0] def cul(exp):
    for v in exp:
        if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

    return Stack[0] cul
import sys


Stack = []
MAX = 1000

def push(x):
    #if isFull():
    #    print "ERROR!"
    #    sys.exit()
    Stack.append(x)

def pop():
    #if isEmpty():
    #    print "ERROR!"
    #    sys.exit()
    Stack.pop(-1)

def cul(exp):
    for v in exp:
        if v == "+":
            x = reduce(lambda a,b:int(a)+int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "-":
            x = reduce(lambda a,b:int(a)-int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        elif v == "*":
            x = reduce(lambda a,b:int(a)*int(b), Stack[-2:])
            for i in range(2):
                pop()
            push(x)
        else:
            push(v)

    return Stack[0]

if __name__ == "__main__":
    exp = sys.stdin.read().strip().split(" ")
    ans = cul(exp)
    print ans