
class Stack():
    def __init__(self):
        self.l = []
    
    def push(self, e):
        self.l.append(e)
        
    def pop(self):
        return self.l.pop()

# def isint(s):
#     try: 
#         int(s)
#         return True
#     except ValueError:
#         return False

ope = {"+", "-", "*"}

s = Stack()
exp = input().strip().split()

for e in exp:
    if e in ope:
        if e == '+':
            s.push(s.pop() + s.pop())
        elif e == '-':
            tmp = s.pop()
            s.push(s.pop() - tmp)
        else:
            s.push(s.pop() * s.pop())
    else:
        s.push(int(e))
print(s.pop()) class Stack():
    def __init__(self):
        self.l = []
    
    def push(self, e):
        self.l.append(e)
        
    def pop(self):
        return self.l.pop()

# def isint(s):
#     try: 
#         int(s)
#         return True
#     except ValueError:
#         return False Stack def __init__(self):
        self.l = []
    
     __init__ self.l = [] self.l self l [] self self def push(self, e):
        self.l.append(e)
        
     push self.l.append(e) self.l.append self.l self l append e self self e e def pop(self):
        return self.l.pop()

# def isint(s):
#     try: 
#         int(s)
#         return True
#     except ValueError:
#         return False pop return self.l.pop() self.l.pop() self.l.pop self.l self l pop self self ope = {"+", "-", "*"} ope {"+", "-", "*"} s = Stack() s Stack() Stack exp = input().strip().split() exp input().strip().split() ().strip().split ().strip() ().strip () input strip split for e in exp:
    if e in ope:
        if e == '+':
            s.push(s.pop() + s.pop())
        elif e == '-':
            tmp = s.pop()
            s.push(s.pop() - tmp)
        else:
            s.push(s.pop() * s.pop())
    else:
        s.push(int(e)) e exp if e in ope:
        if e == '+':
            s.push(s.pop() + s.pop())
        elif e == '-':
            tmp = s.pop()
            s.push(s.pop() - tmp)
        else:
            s.push(s.pop() * s.pop())
    else:
        s.push(int(e)) e in ope e ope if e == '+':
            s.push(s.pop() + s.pop())
        elif e == '-':
            tmp = s.pop()
            s.push(s.pop() - tmp)
        else:
            s.push(s.pop() * s.pop())
     e == '+' e '+' s.push(s.pop() + s.pop()) s.push s push s.pop() + s.pop() s.pop() s.pop s pop s.pop() s.pop s pop elif e == '-':
            tmp = s.pop()
            s.push(s.pop() - tmp)
         e == '-' e '-' tmp = s.pop() tmp s.pop() s.pop s pop s.push(s.pop() - tmp) s.push s push s.pop() - tmp s.pop() s.pop s pop tmp s.push(s.pop() * s.pop()) s.push s push s.pop() * s.pop() s.pop() s.pop s pop s.pop() s.pop s pop s.push(int(e)) s.push s push int(e) int e print(s.pop()) print s.pop() s.pop s pop s = Stack() Stack() s tmp = s.pop() s.pop() tmp exp = input().strip().split() input().strip().split() exp class Stack():
    def __init__(self):
        self.l = []
    
    def push(self, e):
        self.l.append(e)
        
    def pop(self):
        return self.l.pop()

# def isint(s):
#     try: 
#         int(s)
#         return True
#     except ValueError:
#         return False class Stack():
    def __init__(self):
        self.l = []
    
    def push(self, e):
        self.l.append(e)
        
    def pop(self):
        return self.l.pop()

# def isint(s):
#     try: 
#         int(s)
#         return True
#     except ValueError:
#         return False Stack ope = {"+", "-", "*"} {"+", "-", "*"} ope

class Stack():
    def __init__(self):
        self.l = []
    
    def push(self, e):
        self.l.append(e)
        
    def pop(self):
        return self.l.pop()

# def isint(s):
#     try: 
#         int(s)
#         return True
#     except ValueError:
#         return False

ope = {"+", "-", "*"}

s = Stack()
exp = input().strip().split()

for e in exp:
    if e in ope:
        if e == '+':
            s.push(s.pop() + s.pop())
        elif e == '-':
            tmp = s.pop()
            s.push(s.pop() - tmp)
        else:
            s.push(s.pop() * s.pop())
    else:
        s.push(int(e))
print(s.pop())