class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = []

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value)


sequence = raw_input().split()
operators = {"*": "*", "+": "+", "-": "-"}
stack = MyStack()
for s in sequence:
    if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s)

print(stack.pop()) class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = []

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value) MyStack """stack class

    Attributes:
        stack: stack
    """ def __init__(self):
        self.stack = []

     __init__ self.stack = [] self.stack self stack [] self self def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

     pop """pop method

        Returns:
            popped object
        """ return self.stack.pop() self.stack.pop() self.stack.pop self.stack self stack pop self self def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value) push """ push method
        Args:
            value: value to be pushed
        """ self.stack.append(value) self.stack.append self.stack self stack append value self self value value object sequence = raw_input().split() sequence raw_input().split() ().split () raw_input split operators = {"*": "*", "+": "+", "-": "-"} operators {"*": "*", "+": "+", "-": "-"} "*" "*" "*" "+" "+" "+" "-" "-" "-" stack = MyStack() stack MyStack() MyStack for s in sequence:
    if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s) s sequence if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s) s in operators s operators value2 = stack.pop() value2 stack.pop() stack.pop stack pop value1 = stack.pop() value1 stack.pop() stack.pop stack pop stack.push(str(eval(value1 + operators[s] + value2))) stack.push stack push str(eval(value1 + operators[s] + value2)) str eval(value1 + operators[s] + value2) eval value1 + operators[s] + value2 value1 + operators[s] value1 operators[s] operators s value2 stack.push(s) stack.push stack push s print(stack.pop()) print stack.pop() stack.pop stack pop class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = []

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value) class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = []

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value) MyStack operators = {"*": "*", "+": "+", "-": "-"} {"*": "*", "+": "+", "-": "-"} operators value2 = stack.pop() stack.pop() value2 stack = MyStack() MyStack() stack sequence = raw_input().split() raw_input().split() sequence value1 = stack.pop() stack.pop() value1
class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = []

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        return self.stack.pop()

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        self.stack.append(value)


sequence = raw_input().split()
operators = {"*": "*", "+": "+", "-": "-"}
stack = MyStack()
for s in sequence:
    if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s)

print(stack.pop())