class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top]


def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol()


if __name__ == '__main__':
    main() class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top] Stack def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

     __init__ 0 for _ in range(1000) for _ in range(1000) _ range(1000) range 1000 for _ in range(1000) 0 self.stack = [0 for _ in range(1000)] self.stack self stack [0 for _ in range(1000)] self.top = 0 self.top self top 0 self self def push(self, n):
        self.top += 1
        self.stack[self.top] = n

     push self.top += 1 self.top self top 1 self.stack[self.top] = n self.stack[self.top] self.stack self stack self.top self top n self self n n def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

     pop a = self.stack[self.top] a self.stack[self.top] self.stack self stack self.top self top del self.stack[self.top] self.stack[self.top] self.stack self stack self.top self top self.top -= 1 self.top self top 1 return a a self self def lol(self):
        return self.stack[self.top] lol return self.stack[self.top] self.stack[self.top] self.stack self stack self.top self top self self def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol() main input_data = raw_input() input_data raw_input() raw_input data = input_data.strip().split(" ") data input_data.strip().split(" ") input_data.strip().split input_data.strip() input_data.strip input_data strip split " " st = Stack() st Stack() Stack for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

     l data if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

     l == "+" l "+" a = st.pop() a st.pop() st.pop st pop b = st.pop() b st.pop() st.pop st pop st.push(a + b) st.push st push a + b a b elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

         l == "-" l "-" a = st.pop() a st.pop() st.pop st pop b = st.pop() b st.pop() st.pop st pop st.push(b - a) st.push st push b - a b a elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

         l == "*" l "*" a = st.pop() a st.pop() st.pop st pop b = st.pop() b st.pop() st.pop st pop st.push(a * b) st.push st push a * b a b st.push(int(l)) st.push st push int(l) int l print st.lol() st.lol st lol if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top] class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top] Stack def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol() def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol() main
class Stack():
    def __init__(self):
        self.stack = [0 for _ in range(1000)]
        self.top = 0

    def push(self, n):
        self.top += 1
        self.stack[self.top] = n

    def pop(self):
        a = self.stack[self.top]
        del self.stack[self.top]
        self.top -= 1
        return a

    def lol(self):
        return self.stack[self.top]


def main():
    input_data = raw_input()
    data = input_data.strip().split(" ")
    st = Stack()
    for l in data:
        if l == "+":
            a = st.pop()
            b = st.pop()
            st.push(a + b)

        elif l == "-":
            a = st.pop()
            b = st.pop()
            st.push(b - a)

        elif l == "*":
            a = st.pop()
            b = st.pop()
            st.push(a * b)

        else:
            st.push(int(l))

    print st.lol()


if __name__ == '__main__':
    main()