class Node:
    def __init__(self,v):
        self.v = v
        self.next = None


class Stack:
    def __init__(self):
        self.head = None
    def push(self,v):
        n = Node(v)
        n.next = self.head
        self.head = n
    def pop(self):
        if self.head == None:
            return None
        n = self.head
        self.head = self.head.next
        return n.v

ops = raw_input().split(' ')

s = Stack()
for op in ops:
    if op == '+':
        a = s.pop()
        b = s.pop()
        s.push(a+b)
    elif op == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
    elif op == '*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
    else:
        num = int(op)
        s.push(num)

print s.pop() class Node:
    def __init__(self,v):
        self.v = v
        self.next = None Node def __init__(self,v):
        self.v = v
        self.next = None __init__ self.v = v self.v self v v self.next = None self.next self next None self self v v class Stack:
    def __init__(self):
        self.head = None
    def push(self,v):
        n = Node(v)
        n.next = self.head
        self.head = n
    def pop(self):
        if self.head == None:
            return None
        n = self.head
        self.head = self.head.next
        return n.v Stack def __init__(self):
        self.head = None
     __init__ self.head = None self.head self head None self self def push(self,v):
        n = Node(v)
        n.next = self.head
        self.head = n
     push n = Node(v) n Node(v) Node v n.next = self.head n.next n next self.head self head self.head = n self.head self head n self self v v def pop(self):
        if self.head == None:
            return None
        n = self.head
        self.head = self.head.next
        return n.v pop if self.head == None:
            return None
         self.head == None self.head self head None return None None n = self.head n self.head self head self.head = self.head.next self.head self head self.head.next self.head self head next return n.v n.v n v self self ops = raw_input().split(' ') ops raw_input().split(' ') ().split () raw_input split ' ' s = Stack() s Stack() Stack for op in ops:
    if op == '+':
        a = s.pop()
        b = s.pop()
        s.push(a+b)
    elif op == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
    elif op == '*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
    else:
        num = int(op)
        s.push(num) op ops if op == '+':
        a = s.pop()
        b = s.pop()
        s.push(a+b)
    elif op == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
    elif op == '*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
    else:
        num = int(op)
        s.push(num) op == '+' op '+' a = s.pop() a s.pop() s.pop s pop b = s.pop() b s.pop() s.pop s pop s.push(a+b) s.push s push a+b a b elif op == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
     op == '-' op '-' a = s.pop() a s.pop() s.pop s pop b = s.pop() b s.pop() s.pop s pop s.push(b-a) s.push s push b-a b a elif op == '*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
     op == '*' op '*' a = s.pop() a s.pop() s.pop s pop b = s.pop() b s.pop() s.pop s pop s.push(a*b) s.push s push a*b a b num = int(op) num int(op) int op s.push(num) s.push s push num print s.pop() s.pop s pop ops = raw_input().split(' ') raw_input().split(' ') ops b = s.pop() s.pop() b b = s.pop() s.pop() b b = s.pop() s.pop() b a = s.pop() s.pop() a a = s.pop() s.pop() a a = s.pop() s.pop() a class Node:
    def __init__(self,v):
        self.v = v
        self.next = None class Node:
    def __init__(self,v):
        self.v = v
        self.next = None Node class Stack:
    def __init__(self):
        self.head = None
    def push(self,v):
        n = Node(v)
        n.next = self.head
        self.head = n
    def pop(self):
        if self.head == None:
            return None
        n = self.head
        self.head = self.head.next
        return n.v class Stack:
    def __init__(self):
        self.head = None
    def push(self,v):
        n = Node(v)
        n.next = self.head
        self.head = n
    def pop(self):
        if self.head == None:
            return None
        n = self.head
        self.head = self.head.next
        return n.v Stack num = int(op) int(op) num s = Stack() Stack() s
class Node:
    def __init__(self,v):
        self.v = v
        self.next = None


class Stack:
    def __init__(self):
        self.head = None
    def push(self,v):
        n = Node(v)
        n.next = self.head
        self.head = n
    def pop(self):
        if self.head == None:
            return None
        n = self.head
        self.head = self.head.next
        return n.v

ops = raw_input().split(' ')

s = Stack()
for op in ops:
    if op == '+':
        a = s.pop()
        b = s.pop()
        s.push(a+b)
    elif op == '-':
        a = s.pop()
        b = s.pop()
        s.push(b-a)
    elif op == '*':
        a = s.pop()
        b = s.pop()
        s.push(a*b)
    else:
        num = int(op)
        s.push(num)

print s.pop()