# Stack

class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b)


def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop())

main() class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) MyStack def __init__(self):
        self.stack = []
    
     __init__ self.stack = [] self.stack self stack [] self self def pop(self):
        return self.stack.pop()
    
     pop return self.stack.pop() self.stack.pop() self.stack.pop self.stack self stack pop self self def push(self, x):
        self.stack.append(x)

     push self.stack.append(x) self.stack.append self.stack self stack append x self self x x def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
     isEmpty if len(self.stack)==0:
            return True
        else:
            return False
    
     len(self.stack)==0 len(self.stack) len self.stack self stack 0 return True True return False False self self def isFull(self):
        pass
    
     isFull self self def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) calculate if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) type(x)==int type(x) type x int self.push(x) self.push self push x elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) type(x)==str type(x) type x str b = self.pop() b self.pop() self.pop self pop a = self.pop() a self.pop() self.pop self pop if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) x=='+' x '+' self.push(a+b) self.push self push a+b a b elif x=='-':
                self.push(a-b)
             x=='-' x '-' self.push(a-b) self.push self push a-b a b elif x=='*':
                self.push(a*b) x=='*' x '*' self.push(a*b) self.push self push a*b a b self self x x def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop()) main A = list(map(lambda x: int(x) if x.isdigit() else x, input().split())) A list(map(lambda x: int(x) if x.isdigit() else x, input().split())) list map(lambda x: int(x) if x.isdigit() else x, input().split()) map lambda x: int(x) if x.isdigit() else x int(x) if x.isdigit() else x x.isdigit() x.isdigit x isdigit int(x) int x x x input().split() ().split () input split stack = MyStack() stack MyStack() MyStack for a in A:
        stack.calculate(a)
     a A stack.calculate(a) stack.calculate stack calculate a print(stack.pop()) print stack.pop() stack.pop stack pop main() main def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop()) def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop()) main class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b) MyStack
# Stack

class MyStack:
    def __init__(self):
        self.stack = []
    
    def pop(self):
        return self.stack.pop()
    
    def push(self, x):
        self.stack.append(x)

    def isEmpty(self):
        if len(self.stack)==0:
            return True
        else:
            return False
    
    def isFull(self):
        pass
    
    def calculate(self, x):
        if type(x)==int:
            self.push(x)
        elif type(x)==str:
            b = self.pop()
            a = self.pop()
            if x=='+':
                self.push(a+b)
            elif x=='-':
                self.push(a-b)
            elif x=='*':
                self.push(a*b)


def main():
    A = list(map(lambda x: int(x) if x.isdigit() else x, input().split()))
    stack = MyStack()
    for a in A:
        stack.calculate(a)
    print(stack.pop())

main()
