class Stack:
    data_list = []
    def push(self, a):
        self.data_list.append(a)
    def pop(self):
        return self.data_list.pop()

data = input()
lines = data.strip().split()
stack = Stack()
for line in lines:
    if line == '+':
        num = int(stack.pop()) + int(stack.pop())
        stack.push(num)
    elif line == '-':
        num = int(stack.pop()) - int(stack.pop())
        stack.push(-1*num)
    elif line == '*':
        num = int(stack.pop()) * int(stack.pop())
        stack.push(num)
    else:
        stack.push(line)

print(stack.pop()) class Stack:
    data_list = []
    def push(self, a):
        self.data_list.append(a)
    def pop(self):
        return self.data_list.pop() Stack data_list = [] data_list [] def push(self, a):
        self.data_list.append(a)
     push self.data_list.append(a) self.data_list.append self.data_list self data_list append a self self a a def pop(self):
        return self.data_list.pop() pop return self.data_list.pop() self.data_list.pop() self.data_list.pop self.data_list self data_list pop self self data = input() data input() input lines = data.strip().split() lines data.strip().split() data.strip().split data.strip() data.strip data strip split stack = Stack() stack Stack() Stack for line in lines:
    if line == '+':
        num = int(stack.pop()) + int(stack.pop())
        stack.push(num)
    elif line == '-':
        num = int(stack.pop()) - int(stack.pop())
        stack.push(-1*num)
    elif line == '*':
        num = int(stack.pop()) * int(stack.pop())
        stack.push(num)
    else:
        stack.push(line) line lines if line == '+':
        num = int(stack.pop()) + int(stack.pop())
        stack.push(num)
    elif line == '-':
        num = int(stack.pop()) - int(stack.pop())
        stack.push(-1*num)
    elif line == '*':
        num = int(stack.pop()) * int(stack.pop())
        stack.push(num)
    else:
        stack.push(line) line == '+' line '+' num = int(stack.pop()) + int(stack.pop()) num int(stack.pop()) + int(stack.pop()) int(stack.pop()) int stack.pop() stack.pop stack pop int(stack.pop()) int stack.pop() stack.pop stack pop stack.push(num) stack.push stack push num elif line == '-':
        num = int(stack.pop()) - int(stack.pop())
        stack.push(-1*num)
     line == '-' line '-' num = int(stack.pop()) - int(stack.pop()) num int(stack.pop()) - int(stack.pop()) int(stack.pop()) int stack.pop() stack.pop stack pop int(stack.pop()) int stack.pop() stack.pop stack pop stack.push(-1*num) stack.push stack push -1*num -1 num elif line == '*':
        num = int(stack.pop()) * int(stack.pop())
        stack.push(num)
     line == '*' line '*' num = int(stack.pop()) * int(stack.pop()) num int(stack.pop()) * int(stack.pop()) int(stack.pop()) int stack.pop() stack.pop stack pop int(stack.pop()) int stack.pop() stack.pop stack pop stack.push(num) stack.push stack push num stack.push(line) stack.push stack push line print(stack.pop()) print stack.pop() stack.pop stack pop stack = Stack() Stack() stack class Stack:
    data_list = []
    def push(self, a):
        self.data_list.append(a)
    def pop(self):
        return self.data_list.pop() class Stack:
    data_list = []
    def push(self, a):
        self.data_list.append(a)
    def pop(self):
        return self.data_list.pop() Stack num = int(stack.pop()) + int(stack.pop()) int(stack.pop()) + int(stack.pop()) num data = input() input() data num = int(stack.pop()) * int(stack.pop()) int(stack.pop()) * int(stack.pop()) num lines = data.strip().split() data.strip().split() lines num = int(stack.pop()) - int(stack.pop()) int(stack.pop()) - int(stack.pop()) num
class Stack:
    data_list = []
    def push(self, a):
        self.data_list.append(a)
    def pop(self):
        return self.data_list.pop()

data = input()
lines = data.strip().split()
stack = Stack()
for line in lines:
    if line == '+':
        num = int(stack.pop()) + int(stack.pop())
        stack.push(num)
    elif line == '-':
        num = int(stack.pop()) - int(stack.pop())
        stack.push(-1*num)
    elif line == '*':
        num = int(stack.pop()) * int(stack.pop())
        stack.push(num)
    else:
        stack.push(line)

print(stack.pop())
