class Stack:
    def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= MAX - 1
            
    def push(self, e):
        if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
        self.top += 1
           
    def pop(self):
        self.top -= 1
        return self.stack[self.top]

S = input().split(" ")

operators = ["+", "-", "*"]


stack = Stack()
for s in S:
    if s in operators:
        a = stack.pop()
        b = stack.pop()
#         print("%d %s %d"%(a, s, b))
        result = eval("%d %s %d"%(b, s, a))
        stack.push(result)
    else:
        stack.push(int(s))
print (stack.pop()) class Stack:
    def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= MAX - 1
            
    def push(self, e):
        if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
        self.top += 1
           
    def pop(self):
        self.top -= 1
        return self.stack[self.top] Stack def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
     __init__ if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
     type(stack) is type([]) type(stack) type stack type([]) type [] self.stack = stack self.stack self stack stack self.top = len(stack) self.top self top len(stack) len stack self.stack = [] self.stack self stack [] self.top = 0 self.top self top 0 self self stack = None stack None def isEmpty(self):
        return self.top == 0
    
     isEmpty return self.top == 0 self.top == 0 self.top self top 0 self self def isFull(self):
        return self.top >= MAX - 1
            
     isFull return self.top >= MAX - 1 self.top >= MAX - 1 self.top self top MAX - 1 MAX 1 self self def push(self, e):
        if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
        self.top += 1
           
     push if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
         len(self.stack) != (self.top) len(self.stack) len self.stack self stack self.top self top self.stack[self.top] = e self.stack[self.top] self.stack self stack self.top self top e self.stack.append(e) self.stack.append self.stack self stack append e self.top += 1 self.top self top 1 self self e e def pop(self):
        self.top -= 1
        return self.stack[self.top] pop self.top -= 1 self.top self top 1 return self.stack[self.top] self.stack[self.top] self.stack self stack self.top self top self self S = input().split(" ") S input().split(" ") ().split () input split " " operators = ["+", "-", "*"] operators ["+", "-", "*"] "+" "-" "*" stack = Stack() stack Stack() Stack for s in S:
    if s in operators:
        a = stack.pop()
        b = stack.pop()
#         print("%d %s %d"%(a, s, b))
        result = eval("%d %s %d"%(b, s, a))
        stack.push(result)
    else:
        stack.push(int(s)) s S if s in operators:
        a = stack.pop()
        b = stack.pop()
#         print("%d %s %d"%(a, s, b))
        result = eval("%d %s %d"%(b, s, a))
        stack.push(result)
    else:
        stack.push(int(s)) s in operators s operators a = stack.pop() a stack.pop() stack.pop stack pop b = stack.pop() b stack.pop() stack.pop stack pop result = eval("%d %s %d"%(b, s, a)) result eval("%d %s %d"%(b, s, a)) eval "%d %s %d"%(b, s, a) "%d %s %d" (b, s, a) b s a stack.push(result) stack.push stack push result stack.push(int(s)) stack.push stack push int(s) int s print (stack.pop()) print stack.pop() stack.pop stack pop stack = Stack() Stack() stack b = stack.pop() stack.pop() b operators = ["+", "-", "*"] ["+", "-", "*"] operators S = input().split(" ") input().split(" ") S class Stack:
    def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= MAX - 1
            
    def push(self, e):
        if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
        self.top += 1
           
    def pop(self):
        self.top -= 1
        return self.stack[self.top] class Stack:
    def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= MAX - 1
            
    def push(self, e):
        if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
        self.top += 1
           
    def pop(self):
        self.top -= 1
        return self.stack[self.top] Stack a = stack.pop() stack.pop() a result = eval("%d %s %d"%(b, s, a)) eval("%d %s %d"%(b, s, a)) result
class Stack:
    def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
            self.top = len(stack)
        else:
            self.stack = []
            self.top = 0
            
    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= MAX - 1
            
    def push(self, e):
        if len(self.stack) != (self.top):
            self.stack[self.top] = e
        else:
            self.stack.append(e)
        self.top += 1
           
    def pop(self):
        self.top -= 1
        return self.stack[self.top]

S = input().split(" ")

operators = ["+", "-", "*"]


stack = Stack()
for s in S:
    if s in operators:
        a = stack.pop()
        b = stack.pop()
#         print("%d %s %d"%(a, s, b))
        result = eval("%d %s %d"%(b, s, a))
        stack.push(result)
    else:
        stack.push(int(s))
print (stack.pop())