class Stack():
    def __init__(self):
        self.el = []
        
    def add(self, el):
        self.el.append(el)
        
    def pop(self):
        return self.el.pop()

    def isEmpty(self):
        if len(self.el) == 0:
            return True
        else:
            return False

        
a = raw_input().split()
#print a
st = Stack()

for index in range(len(a)):
    #print a[index]
    if a[index] in ['+', '-', '*']:
        num1 = st.pop()
        num2 = st.pop()
        if a[index] == '+':
            st.add(int(num1) + int(num2))
        elif a[index] == '-':
            st.add(int(num2) - int(num1))
        else:
            st.add(int(num1) * int(num2))
    else:
        st.add(a[index])
    #print st.el

ans = st.pop()
print ans class Stack():
    def __init__(self):
        self.el = []
        
    def add(self, el):
        self.el.append(el)
        
    def pop(self):
        return self.el.pop()

    def isEmpty(self):
        if len(self.el) == 0:
            return True
        else:
            return False

         Stack def __init__(self):
        self.el = []
        
     __init__ self.el = [] self.el self el [] self self def add(self, el):
        self.el.append(el)
        
     add self.el.append(el) self.el.append self.el self el append el self self el el def pop(self):
        return self.el.pop()

     pop return self.el.pop() self.el.pop() self.el.pop self.el self el pop self self def isEmpty(self):
        if len(self.el) == 0:
            return True
        else:
            return False

         isEmpty if len(self.el) == 0:
            return True
        else:
            return False

         len(self.el) == 0 len(self.el) len self.el self el 0 return True True return False False self self a = raw_input().split() a raw_input().split() ().split () raw_input split st = Stack() st Stack() Stack for index in range(len(a)):
    #print a[index]
    if a[index] in ['+', '-', '*']:
        num1 = st.pop()
        num2 = st.pop()
        if a[index] == '+':
            st.add(int(num1) + int(num2))
        elif a[index] == '-':
            st.add(int(num2) - int(num1))
        else:
            st.add(int(num1) * int(num2))
    else:
        st.add(a[index])
    #print st.el index range(len(a)) range len(a) len a if a[index] in ['+', '-', '*']:
        num1 = st.pop()
        num2 = st.pop()
        if a[index] == '+':
            st.add(int(num1) + int(num2))
        elif a[index] == '-':
            st.add(int(num2) - int(num1))
        else:
            st.add(int(num1) * int(num2))
    else:
        st.add(a[index])
    #print st.el a[index] in ['+', '-', '*'] a[index] a index ['+', '-', '*'] '+' '-' '*' num1 = st.pop() num1 st.pop() st.pop st pop num2 = st.pop() num2 st.pop() st.pop st pop if a[index] == '+':
            st.add(int(num1) + int(num2))
        elif a[index] == '-':
            st.add(int(num2) - int(num1))
        else:
            st.add(int(num1) * int(num2))
     a[index] == '+' a[index] a index '+' st.add(int(num1) + int(num2)) st.add st add int(num1) + int(num2) int(num1) int num1 int(num2) int num2 elif a[index] == '-':
            st.add(int(num2) - int(num1))
         a[index] == '-' a[index] a index '-' st.add(int(num2) - int(num1)) st.add st add int(num2) - int(num1) int(num2) int num2 int(num1) int num1 st.add(int(num1) * int(num2)) st.add st add int(num1) * int(num2) int(num1) int num1 int(num2) int num2 st.add(a[index]) st.add st add a[index] a index ans = st.pop() ans st.pop() st.pop st pop print num2 = st.pop() st.pop() num2 a = raw_input().split() raw_input().split() a ans = st.pop() st.pop() ans st = Stack() Stack() st num1 = st.pop() st.pop() num1 class Stack():
    def __init__(self):
        self.el = []
        
    def add(self, el):
        self.el.append(el)
        
    def pop(self):
        return self.el.pop()

    def isEmpty(self):
        if len(self.el) == 0:
            return True
        else:
            return False

         class Stack():
    def __init__(self):
        self.el = []
        
    def add(self, el):
        self.el.append(el)
        
    def pop(self):
        return self.el.pop()

    def isEmpty(self):
        if len(self.el) == 0:
            return True
        else:
            return False

         Stack
class Stack():
    def __init__(self):
        self.el = []
        
    def add(self, el):
        self.el.append(el)
        
    def pop(self):
        return self.el.pop()

    def isEmpty(self):
        if len(self.el) == 0:
            return True
        else:
            return False

        
a = raw_input().split()
#print a
st = Stack()

for index in range(len(a)):
    #print a[index]
    if a[index] in ['+', '-', '*']:
        num1 = st.pop()
        num2 = st.pop()
        if a[index] == '+':
            st.add(int(num1) + int(num2))
        elif a[index] == '-':
            st.add(int(num2) - int(num1))
        else:
            st.add(int(num1) * int(num2))
    else:
        st.add(a[index])
    #print st.el

ans = st.pop()
print ans