class Stack:
    # ???????????????????????§??????top??????????????????????????????Max???isFull??¨????????????stack???????????????????????§???
    def __init__(self):
        self.top = 0
        self.Max = 100
        self.stack = [None]

    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= self.Max

    def push(self, x):
        if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

    def pop(self):
        if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop()

d_e = input().split()

accumlator = Stack()

for i in d_e:
    if i in "+-*":
        post_op = accumlator.pop()
        pre_op = accumlator.pop()
        ans = eval(pre_op + i + post_op)
        accumlator.push(str(ans))
    else:
        accumlator.push(i)

print(int(accumlator.pop())) class Stack:
    # ???????????????????????§??????top??????????????????????????????Max???isFull??¨????????????stack???????????????????????§???
    def __init__(self):
        self.top = 0
        self.Max = 100
        self.stack = [None]

    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= self.Max

    def push(self, x):
        if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

    def pop(self):
        if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop() Stack def __init__(self):
        self.top = 0
        self.Max = 100
        self.stack = [None]

     __init__ self.top = 0 self.top self top 0 self.Max = 100 self.Max self Max 100 self.stack = [None] self.stack self stack [None] None self self def isEmpty(self):
        return self.top == 0
    
     isEmpty return self.top == 0 self.top == 0 self.top self top 0 self self def isFull(self):
        return self.top >= self.Max

     isFull return self.top >= self.Max self.top >= self.Max self.top self top self.Max self Max self self def push(self, x):
        if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

     push if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

     self.isFull() self.isFull self isFull print("Stack overflow!") print "Stack overflow!" self.top += 1 self.top self top 1 self.stack.append(x) self.stack.append self.stack self stack append x self self x x def pop(self):
        if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop() pop if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop() self.isEmpty() self.isEmpty self isEmpty print("Stack underflow!") print "Stack underflow!" self.top -= 1 self.top self top 1 return self.stack.pop() self.stack.pop() self.stack.pop self.stack self stack pop self self d_e = input().split() d_e input().split() ().split () input split accumlator = Stack() accumlator Stack() Stack for i in d_e:
    if i in "+-*":
        post_op = accumlator.pop()
        pre_op = accumlator.pop()
        ans = eval(pre_op + i + post_op)
        accumlator.push(str(ans))
    else:
        accumlator.push(i) i d_e if i in "+-*":
        post_op = accumlator.pop()
        pre_op = accumlator.pop()
        ans = eval(pre_op + i + post_op)
        accumlator.push(str(ans))
    else:
        accumlator.push(i) i in "+-*" i "+-*" post_op = accumlator.pop() post_op accumlator.pop() accumlator.pop accumlator pop pre_op = accumlator.pop() pre_op accumlator.pop() accumlator.pop accumlator pop ans = eval(pre_op + i + post_op) ans eval(pre_op + i + post_op) eval pre_op + i + post_op pre_op + i pre_op i post_op accumlator.push(str(ans)) accumlator.push accumlator push str(ans) str ans accumlator.push(i) accumlator.push accumlator push i print(int(accumlator.pop())) print int(accumlator.pop()) int accumlator.pop() accumlator.pop accumlator pop ans = eval(pre_op + i + post_op) eval(pre_op + i + post_op) ans pre_op = accumlator.pop() accumlator.pop() pre_op class Stack:
    # ???????????????????????§??????top??????????????????????????????Max???isFull??¨????????????stack???????????????????????§???
    def __init__(self):
        self.top = 0
        self.Max = 100
        self.stack = [None]

    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= self.Max

    def push(self, x):
        if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

    def pop(self):
        if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop() class Stack:
    # ???????????????????????§??????top??????????????????????????????Max???isFull??¨????????????stack???????????????????????§???
    def __init__(self):
        self.top = 0
        self.Max = 100
        self.stack = [None]

    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= self.Max

    def push(self, x):
        if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

    def pop(self):
        if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop() Stack d_e = input().split() input().split() d_e accumlator = Stack() Stack() accumlator post_op = accumlator.pop() accumlator.pop() post_op
class Stack:
    # ???????????????????????§??????top??????????????????????????????Max???isFull??¨????????????stack???????????????????????§???
    def __init__(self):
        self.top = 0
        self.Max = 100
        self.stack = [None]

    def isEmpty(self):
        return self.top == 0
    
    def isFull(self):
        return self.top >= self.Max

    def push(self, x):
        if self.isFull():
            print("Stack overflow!")
        else:
            self.top += 1
            self.stack.append(x)

    def pop(self):
        if self.isEmpty():
            print("Stack underflow!")
        else:
            self.top -= 1
            return self.stack.pop()

d_e = input().split()

accumlator = Stack()

for i in d_e:
    if i in "+-*":
        post_op = accumlator.pop()
        pre_op = accumlator.pop()
        ans = eval(pre_op + i + post_op)
        accumlator.push(str(ans))
    else:
        accumlator.push(i)

print(int(accumlator.pop()))