class Node(object):
    def __init__(self, c):
        self.c = c
        self.left = None
        self.right = None

def print_node(node):
    print node.c
    if node.left != None:
        print_node(node.left)
    if node.right != None:
        print_node(node.right)

def calc_node(node):
    if node.c in ('+', '-', '/', '*'):
        if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
        if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
        if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
    else:
        return int(node.c)

def make_node(s):
    global pos
    node = Node(s[pos])
    if s[pos] in ('+', '-', '*'):
        pos += 1
        node.right = make_node(s)
        pos += 1
        node.left = make_node(s)
    return node

s = raw_input().split()
s.reverse()
#print s
pos = 0
n = make_node(s)
#print_node(n)
print "%d" % calc_node(n) class Node(object):
    def __init__(self, c):
        self.c = c
        self.left = None
        self.right = None Node def __init__(self, c):
        self.c = c
        self.left = None
        self.right = None __init__ self.c = c self.c self c c self.left = None self.left self left None self.right = None self.right self right None self self c c object def print_node(node):
    print node.c
    if node.left != None:
        print_node(node.left)
    if node.right != None:
        print_node(node.right) print_node print node.c node c if node.left != None:
        print_node(node.left)
     node.left != None node.left node left None print_node(node.left) print_node node.left node left if node.right != None:
        print_node(node.right) node.right != None node.right node right None print_node(node.right) print_node node.right node right node node def calc_node(node):
    if node.c in ('+', '-', '/', '*'):
        if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
        if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
        if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
    else:
        return int(node.c) calc_node if node.c in ('+', '-', '/', '*'):
        if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
        if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
        if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
    else:
        return int(node.c) node.c in ('+', '-', '/', '*') node.c node c ('+', '-', '/', '*') '+' '-' '/' '*' if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
         node.c == '+' node.c node c '+' return calc_node(node.left) + calc_node(node.right) calc_node(node.left) + calc_node(node.right) calc_node(node.left) calc_node node.left node left calc_node(node.right) calc_node node.right node right if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
         node.c == '-' node.c node c '-' return calc_node(node.left) - calc_node(node.right) calc_node(node.left) - calc_node(node.right) calc_node(node.left) calc_node node.left node left calc_node(node.right) calc_node node.right node right if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
     node.c == '*' node.c node c '*' return calc_node(node.left) * calc_node(node.right) calc_node(node.left) * calc_node(node.right) calc_node(node.left) calc_node node.left node left calc_node(node.right) calc_node node.right node right return int(node.c) int(node.c) int node.c node c node node def make_node(s):
    global pos
    node = Node(s[pos])
    if s[pos] in ('+', '-', '*'):
        pos += 1
        node.right = make_node(s)
        pos += 1
        node.left = make_node(s)
    return node make_node global pos node = Node(s[pos]) node Node(s[pos]) Node s[pos] s pos if s[pos] in ('+', '-', '*'):
        pos += 1
        node.right = make_node(s)
        pos += 1
        node.left = make_node(s)
     s[pos] in ('+', '-', '*') s[pos] s pos ('+', '-', '*') '+' '-' '*' pos += 1 pos 1 node.right = make_node(s) node.right node right make_node(s) make_node s pos += 1 pos 1 node.left = make_node(s) node.left node left make_node(s) make_node s return node node s s s = raw_input().split() s raw_input().split() ().split () raw_input split s.reverse() s.reverse s reverse pos = 0 pos 0 n = make_node(s) n make_node(s) make_node s print "%d" % calc_node(n) "%d" calc_node(n) calc_node n n = make_node(s) make_node(s) n class Node(object):
    def __init__(self, c):
        self.c = c
        self.left = None
        self.right = None class Node(object):
    def __init__(self, c):
        self.c = c
        self.left = None
        self.right = None Node def print_node(node):
    print node.c
    if node.left != None:
        print_node(node.left)
    if node.right != None:
        print_node(node.right) def print_node(node):
    print node.c
    if node.left != None:
        print_node(node.left)
    if node.right != None:
        print_node(node.right) print_node s = raw_input().split() raw_input().split() s pos = 0 0 pos def calc_node(node):
    if node.c in ('+', '-', '/', '*'):
        if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
        if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
        if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
    else:
        return int(node.c) def calc_node(node):
    if node.c in ('+', '-', '/', '*'):
        if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
        if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
        if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
    else:
        return int(node.c) calc_node def make_node(s):
    global pos
    node = Node(s[pos])
    if s[pos] in ('+', '-', '*'):
        pos += 1
        node.right = make_node(s)
        pos += 1
        node.left = make_node(s)
    return node def make_node(s):
    global pos
    node = Node(s[pos])
    if s[pos] in ('+', '-', '*'):
        pos += 1
        node.right = make_node(s)
        pos += 1
        node.left = make_node(s)
    return node make_node
class Node(object):
    def __init__(self, c):
        self.c = c
        self.left = None
        self.right = None

def print_node(node):
    print node.c
    if node.left != None:
        print_node(node.left)
    if node.right != None:
        print_node(node.right)

def calc_node(node):
    if node.c in ('+', '-', '/', '*'):
        if node.c == '+':
            return calc_node(node.left) + calc_node(node.right)
        if node.c == '-':
            return calc_node(node.left) - calc_node(node.right)
        if node.c == '*':
            return calc_node(node.left) * calc_node(node.right)
    else:
        return int(node.c)

def make_node(s):
    global pos
    node = Node(s[pos])
    if s[pos] in ('+', '-', '*'):
        pos += 1
        node.right = make_node(s)
        pos += 1
        node.left = make_node(s)
    return node

s = raw_input().split()
s.reverse()
#print s
pos = 0
n = make_node(s)
#print_node(n)
print "%d" % calc_node(n)