class Stack(object):
    def __init__(self, _max):
        if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

    def push(self, value):
        if self.isFull():
            raise IndexError
        self._array[self._next] = value
        self._next += 1

    def pop(self):
        if self.isEmpty():
            raise IndexError
        self._next -= 1
        value = self._array[self._next]
        self._array[self._next] = None
        return value

    def isEmpty(self):
        return self._next <= 0

    def isFull(self):
        return self._next >= len(self._array)


def calculator(exp):
    stack = Stack(100)
    ope = ["+", "-", "*"]
    for item in exp:
        if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
    return stack.pop()


if __name__ == "__main__":
    exp = input().split()
    print(calculator(exp)) class Stack(object):
    def __init__(self, _max):
        if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

    def push(self, value):
        if self.isFull():
            raise IndexError
        self._array[self._next] = value
        self._next += 1

    def pop(self):
        if self.isEmpty():
            raise IndexError
        self._next -= 1
        value = self._array[self._next]
        self._array[self._next] = None
        return value

    def isEmpty(self):
        return self._next <= 0

    def isFull(self):
        return self._next >= len(self._array) Stack def __init__(self, _max):
        if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

     __init__ if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

     type(_max) == int type(_max) type _max int None for i in range(0, _max) for i in range(0, _max) i range(0, _max) range 0 _max for i in range(0, _max) None self._array = [None for i in range(0, _max)] self._array self _array [None for i in range(0, _max)] self._next = 0 self._next self _next 0 self self _max _max def push(self, value):
        if self.isFull():
            raise IndexError
        self._array[self._next] = value
        self._next += 1

     push if self.isFull():
            raise IndexError
         self.isFull() self.isFull self isFull raise IndexError IndexError self._array[self._next] = value self._array[self._next] self._array self _array self._next self _next value self._next += 1 self._next self _next 1 self self value value def pop(self):
        if self.isEmpty():
            raise IndexError
        self._next -= 1
        value = self._array[self._next]
        self._array[self._next] = None
        return value

     pop if self.isEmpty():
            raise IndexError
         self.isEmpty() self.isEmpty self isEmpty raise IndexError IndexError self._next -= 1 self._next self _next 1 value = self._array[self._next] value self._array[self._next] self._array self _array self._next self _next self._array[self._next] = None self._array[self._next] self._array self _array self._next self _next None return value value self self def isEmpty(self):
        return self._next <= 0

     isEmpty return self._next <= 0 self._next <= 0 self._next self _next 0 self self def isFull(self):
        return self._next >= len(self._array) isFull return self._next >= len(self._array) self._next >= len(self._array) self._next self _next len(self._array) len self._array self _array self self object def calculator(exp):
    stack = Stack(100)
    ope = ["+", "-", "*"]
    for item in exp:
        if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
    return stack.pop() calculator stack = Stack(100) stack Stack(100) Stack 100 ope = ["+", "-", "*"] ope ["+", "-", "*"] "+" "-" "*" for item in exp:
        if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
     item exp if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
     item in ope item ope val1 = stack.pop() val1 stack.pop() stack.pop stack pop val2 = stack.pop() val2 stack.pop() stack.pop stack pop if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
         item == "+" item "+" stack.push(val2 + val1) stack.push stack push val2 + val1 val2 val1 elif item == "-":
                stack.push(val2 - val1)
             item == "-" item "-" stack.push(val2 - val1) stack.push stack push val2 - val1 val2 val1 elif item == "*":
                stack.push(val2 * val1)
             item == "*" item "*" stack.push(val2 * val1) stack.push stack push val2 * val1 val2 val1 raise ValueError ValueError stack.push(int(item)) stack.push stack push int(item) int item return stack.pop() stack.pop() stack.pop stack pop exp exp if __name__ == "__main__":
    exp = input().split()
    print(calculator(exp)) __name__ == "__main__" __name__ "__main__" exp = input().split() exp input().split() ().split () input split print(calculator(exp)) print calculator(exp) calculator exp class Stack(object):
    def __init__(self, _max):
        if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

    def push(self, value):
        if self.isFull():
            raise IndexError
        self._array[self._next] = value
        self._next += 1

    def pop(self):
        if self.isEmpty():
            raise IndexError
        self._next -= 1
        value = self._array[self._next]
        self._array[self._next] = None
        return value

    def isEmpty(self):
        return self._next <= 0

    def isFull(self):
        return self._next >= len(self._array) class Stack(object):
    def __init__(self, _max):
        if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

    def push(self, value):
        if self.isFull():
            raise IndexError
        self._array[self._next] = value
        self._next += 1

    def pop(self):
        if self.isEmpty():
            raise IndexError
        self._next -= 1
        value = self._array[self._next]
        self._array[self._next] = None
        return value

    def isEmpty(self):
        return self._next <= 0

    def isFull(self):
        return self._next >= len(self._array) Stack def calculator(exp):
    stack = Stack(100)
    ope = ["+", "-", "*"]
    for item in exp:
        if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
    return stack.pop() def calculator(exp):
    stack = Stack(100)
    ope = ["+", "-", "*"]
    for item in exp:
        if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
    return stack.pop() calculator exp = input().split() input().split() exp
class Stack(object):
    def __init__(self, _max):
        if type(_max) == int:
            self._array = [None for i in range(0, _max)]
            self._next = 0

    def push(self, value):
        if self.isFull():
            raise IndexError
        self._array[self._next] = value
        self._next += 1

    def pop(self):
        if self.isEmpty():
            raise IndexError
        self._next -= 1
        value = self._array[self._next]
        self._array[self._next] = None
        return value

    def isEmpty(self):
        return self._next <= 0

    def isFull(self):
        return self._next >= len(self._array)


def calculator(exp):
    stack = Stack(100)
    ope = ["+", "-", "*"]
    for item in exp:
        if item in ope:
            val1 = stack.pop()
            val2 = stack.pop()
            if item == "+":
                stack.push(val2 + val1)
            elif item == "-":
                stack.push(val2 - val1)
            elif item == "*":
                stack.push(val2 * val1)
            else:
                raise ValueError
        else:
            stack.push(int(item))
    return stack.pop()


if __name__ == "__main__":
    exp = input().split()
    print(calculator(exp))