def reverse_polish_calculator(s):
    """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """
    def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

    stack = []
    for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

    return stack.pop()


def run():
    s = input()
    print(reverse_polish_calculator(s))


if __name__ == '__main__':
    run() def reverse_polish_calculator(s):
    """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """
    def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

    stack = []
    for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

    return stack.pop() reverse_polish_calculator """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """ def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

     calc if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

     op == '+' op '+' return val1 + val2 val1 + val2 val1 val2 elif op == '-':
            return val1 - val2
         op == '-' op '-' return val1 - val2 val1 - val2 val1 val2 elif op == '*':
            return val1 * val2
         op == '*' op '*' return val1 * val2 val1 * val2 val1 val2 raise ValueError() ValueError() ValueError val1 val1 op op val2 val2 stack = [] stack [] for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

     c s.split() s.split s split if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

     c.isnumeric() c.isnumeric c isnumeric stack.append(int(c)) stack.append stack append int(c) int c v2 = stack.pop() v2 stack.pop() stack.pop stack pop v1 = stack.pop() v1 stack.pop() stack.pop stack pop stack.append(calc(v1, c, v2)) stack.append stack append calc(v1, c, v2) calc v1 c v2 return stack.pop() stack.pop() stack.pop stack pop s s def run():
    s = input()
    print(reverse_polish_calculator(s)) run s = input() s input() input print(reverse_polish_calculator(s)) print reverse_polish_calculator(s) reverse_polish_calculator s if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def reverse_polish_calculator(s):
    """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """
    def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

    stack = []
    for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

    return stack.pop() def reverse_polish_calculator(s):
    """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """
    def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

    stack = []
    for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

    return stack.pop() reverse_polish_calculator def run():
    s = input()
    print(reverse_polish_calculator(s)) def run():
    s = input()
    print(reverse_polish_calculator(s)) run
def reverse_polish_calculator(s):
    """Calculate a reverse polish notation s.
    + - * operators can be used in s. Only positive integer is
    supported for operand.

    >>> reverse_polish_calculator("1 2 +")
    3
    >>> reverse_polish_calculator("1 2 + 3 4 - *")
    -3
    """
    def calc(val1, op, val2):
        if op == '+':
            return val1 + val2
        elif op == '-':
            return val1 - val2
        elif op == '*':
            return val1 * val2
        else:
            raise ValueError()

    stack = []
    for c in s.split():
        if c.isnumeric():
            stack.append(int(c))
        else:
            v2 = stack.pop()
            v1 = stack.pop()
            stack.append(calc(v1, c, v2))

    return stack.pop()


def run():
    s = input()
    print(reverse_polish_calculator(s))


if __name__ == '__main__':
    run()
