#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
#????????????
#????????????python???????????????????????????????????????push???pop?????????
#??????????????????????????°????????§??????????§£???????????\??£???

def rpn(formula):
    stack = Stack()
    
    for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
    return stack.pop()

class Stack:
    def __init__(self):
        self.data = []

    def push(self, d):
        #print(self.data)
        self.data.append(d)
        
    def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
    
def main():
    formula = input().split()
    print(rpn(formula))
    
if __name__ == "__main__":
    main() def rpn(formula):
    stack = Stack()
    
    for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
    return stack.pop() rpn stack = Stack() stack Stack() Stack for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
     d formula if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
     d == "+" d "+" stack.push(stack.pop() + stack.pop()) stack.push stack push stack.pop() + stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop elif d == "-":
            stack.push(-stack.pop() + stack.pop())
         d == "-" d "-" stack.push(-stack.pop() + stack.pop()) stack.push stack push -stack.pop() + stack.pop() -stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop elif d == "*":
            stack.push(stack.pop() * stack.pop())
         d == "*" d "*" stack.push(stack.pop() * stack.pop()) stack.push stack push stack.pop() * stack.pop() stack.pop() stack.pop stack pop stack.pop() stack.pop stack pop stack.push(int(d)) stack.push stack push int(d) int d return stack.pop() stack.pop() stack.pop stack pop formula formula class Stack:
    def __init__(self):
        self.data = []

    def push(self, d):
        #print(self.data)
        self.data.append(d)
        
    def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
     Stack def __init__(self):
        self.data = []

     __init__ self.data = [] self.data self data [] self self def push(self, d):
        #print(self.data)
        self.data.append(d)
        
     push self.data.append(d) self.data.append self.data self data append d self self d d def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
     pop r = self.data[-1] r self.data[-1] self.data self data -1 self.data = self.data[:-1] self.data self data self.data[:-1] self.data self data :-1 -1 return r r self self def main():
    formula = input().split()
    print(rpn(formula))
     main formula = input().split() formula input().split() ().split () input split print(rpn(formula)) print rpn(formula) rpn formula if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def rpn(formula):
    stack = Stack()
    
    for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
    return stack.pop() def rpn(formula):
    stack = Stack()
    
    for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
    return stack.pop() rpn def main():
    formula = input().split()
    print(rpn(formula))
     def main():
    formula = input().split()
    print(rpn(formula))
     main class Stack:
    def __init__(self):
        self.data = []

    def push(self, d):
        #print(self.data)
        self.data.append(d)
        
    def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
     class Stack:
    def __init__(self):
        self.data = []

    def push(self, d):
        #print(self.data)
        self.data.append(d)
        
    def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
     Stack
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
#????????????
#????????????python???????????????????????????????????????push???pop?????????
#??????????????????????????°????????§??????????§£???????????\??£???

def rpn(formula):
    stack = Stack()
    
    for d in formula:
        if d == "+":
            stack.push(stack.pop() + stack.pop())
        elif d == "-":
            stack.push(-stack.pop() + stack.pop())
        elif d == "*":
            stack.push(stack.pop() * stack.pop())
        else:
            stack.push(int(d))
            
    return stack.pop()

class Stack:
    def __init__(self):
        self.data = []

    def push(self, d):
        #print(self.data)
        self.data.append(d)
        
    def pop(self):
        #print(self.data)
        r = self.data[-1]
        self.data = self.data[:-1]
        return r
    
def main():
    formula = input().split()
    print(rpn(formula))
    
if __name__ == "__main__":
    main()