class Stack:
    def __init__(self):
        self.values = []
        self.n = 0

    def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

    def push(self,x):
        self.values.append(x)
        self.n += 1


operators = set(['+', '-', '*'])
stack = Stack()

for op in raw_input().split(' '):
    if op in operators:
        b = stack.pop()
        a = stack.pop()
        if op == '+':
            stack.push(a+b)
        elif op == '-':
            stack.push(a-b)
        elif op == '*':
            stack.push(a*b)
        else:
            raise Exception("Unkown operator")
    else:
        stack.push(int(op))

print stack.pop() class Stack:
    def __init__(self):
        self.values = []
        self.n = 0

    def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

    def push(self,x):
        self.values.append(x)
        self.n += 1 Stack def __init__(self):
        self.values = []
        self.n = 0

     __init__ self.values = [] self.values self values [] self.n = 0 self.n self n 0 self self def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

     pop if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

     self.n == 0 self.n self n 0 raise Exception("stack underflow") Exception("stack underflow") Exception "stack underflow" v = self.values[-1] v self.values[-1] self.values self values -1 del self.values[-1] self.values[-1] self.values self values -1 self.n -= 1 self.n self n 1 return v v self self def push(self,x):
        self.values.append(x)
        self.n += 1 push self.values.append(x) self.values.append self.values self values append x self.n += 1 self.n self n 1 self self x x operators = set(['+', '-', '*']) operators set(['+', '-', '*']) set ['+', '-', '*'] '+' '-' '*' stack = Stack() stack Stack() Stack for op in raw_input().split(' '):
    if op in operators:
        b = stack.pop()
        a = stack.pop()
        if op == '+':
            stack.push(a+b)
        elif op == '-':
            stack.push(a-b)
        elif op == '*':
            stack.push(a*b)
        else:
            raise Exception("Unkown operator")
    else:
        stack.push(int(op)) op raw_input().split(' ') ().split () raw_input split ' ' if op in operators:
        b = stack.pop()
        a = stack.pop()
        if op == '+':
            stack.push(a+b)
        elif op == '-':
            stack.push(a-b)
        elif op == '*':
            stack.push(a*b)
        else:
            raise Exception("Unkown operator")
    else:
        stack.push(int(op)) op in operators op operators b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop if op == '+':
            stack.push(a+b)
        elif op == '-':
            stack.push(a-b)
        elif op == '*':
            stack.push(a*b)
        else:
            raise Exception("Unkown operator")
     op == '+' op '+' stack.push(a+b) stack.push stack push a+b a b elif op == '-':
            stack.push(a-b)
         op == '-' op '-' stack.push(a-b) stack.push stack push a-b a b elif op == '*':
            stack.push(a*b)
         op == '*' op '*' stack.push(a*b) stack.push stack push a*b a b raise Exception("Unkown operator") Exception("Unkown operator") Exception "Unkown operator" stack.push(int(op)) stack.push stack push int(op) int op print stack.pop() stack.pop stack pop operators = set(['+', '-', '*']) set(['+', '-', '*']) operators stack = Stack() Stack() stack class Stack:
    def __init__(self):
        self.values = []
        self.n = 0

    def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

    def push(self,x):
        self.values.append(x)
        self.n += 1 class Stack:
    def __init__(self):
        self.values = []
        self.n = 0

    def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

    def push(self,x):
        self.values.append(x)
        self.n += 1 Stack b = stack.pop() stack.pop() b a = stack.pop() stack.pop() a
class Stack:
    def __init__(self):
        self.values = []
        self.n = 0

    def pop(self):
        if self.n == 0:
            raise Exception("stack underflow")
        else:
            v = self.values[-1]
            del self.values[-1]
            self.n -= 1
            return v

    def push(self,x):
        self.values.append(x)
        self.n += 1


operators = set(['+', '-', '*'])
stack = Stack()

for op in raw_input().split(' '):
    if op in operators:
        b = stack.pop()
        a = stack.pop()
        if op == '+':
            stack.push(a+b)
        elif op == '-':
            stack.push(a-b)
        elif op == '*':
            stack.push(a*b)
        else:
            raise Exception("Unkown operator")
    else:
        stack.push(int(op))

print stack.pop()