# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
# Stack
# Result:
import sys

class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val

def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2)

items = sys.stdin.readline().rstrip().split(' ')
stack = Stack()

for e in items:
    if e == '+':
        v = calculate(stack, lambda v1, v2: v1 + v2)
    elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
    elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
    else:
        # numbers
        v = int(e)
    stack.push(v)

print stack.pop() import sys sys class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val Stack def __init__(self):
        self.store = []

     __init__ self.store = [] self.store self store [] self self def push(self, item):
        self.store.append(item)

     push self.store.append(item) self.store.append self.store self store append item self self item item def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

     pop if self.is_empty():
            return None
         self.is_empty() self.is_empty self is_empty return None None return self.store.pop() self.store.pop() self.store.pop self.store self store pop self self def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

     is_empty if len(self.store) == 0:
            return True
        else:
            return False

     len(self.store) == 0 len(self.store) len self.store self store 0 return True True return False False self self def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val __str__ """Show top to bottom""" val = '' val '' for e in reversed(self.store):
            val += str(e) + ' '
         e reversed(self.store) reversed self.store self store val += str(e) + ' ' val str(e) + ' ' str(e) str e ' ' return val val self self def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2) calculate v2 = stack.pop() v2 stack.pop() stack.pop stack pop v1 = stack.pop() v1 stack.pop() stack.pop stack pop return func(v1, v2) func(v1, v2) func v1 v2 stack stack func func items = sys.stdin.readline().rstrip().split(' ') items sys.stdin.readline().rstrip().split(' ') sys.stdin.readline().rstrip().split sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip split ' ' stack = Stack() stack Stack() Stack for e in items:
    if e == '+':
        v = calculate(stack, lambda v1, v2: v1 + v2)
    elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
    elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
    else:
        # numbers
        v = int(e)
    stack.push(v) e items if e == '+':
        v = calculate(stack, lambda v1, v2: v1 + v2)
    elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
    elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
    else:
        # numbers
        v = int(e)
     e == '+' e '+' v = calculate(stack, lambda v1, v2: v1 + v2) v calculate(stack, lambda v1, v2: v1 + v2) calculate stack lambda v1, v2: v1 + v2 v1 + v2 v1 v2 v1 v2 elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
     e == '-' e '-' v = calculate(stack, lambda v1, v2: v1 - v2) v calculate(stack, lambda v1, v2: v1 - v2) calculate stack lambda v1, v2: v1 - v2 v1 - v2 v1 v2 v1 v2 elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
     e == '*' e '*' v = calculate(stack, lambda v1, v2: v1 * v2) v calculate(stack, lambda v1, v2: v1 * v2) calculate stack lambda v1, v2: v1 * v2 v1 * v2 v1 v2 v1 v2 v = int(e) v int(e) int e stack.push(v) stack.push stack push v print stack.pop() stack.pop stack pop class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val Stack items = sys.stdin.readline().rstrip().split(' ') sys.stdin.readline().rstrip().split(' ') items v = calculate(stack, lambda v1, v2: v1 - v2) calculate(stack, lambda v1, v2: v1 - v2) v v = int(e) int(e) v v = calculate(stack, lambda v1, v2: v1 + v2) calculate(stack, lambda v1, v2: v1 + v2) v stack = Stack() Stack() stack v = calculate(stack, lambda v1, v2: v1 * v2) calculate(stack, lambda v1, v2: v1 * v2) v def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2) def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2) calculate
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
# Stack
# Result:
import sys

class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val

def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2)

items = sys.stdin.readline().rstrip().split(' ')
stack = Stack()

for e in items:
    if e == '+':
        v = calculate(stack, lambda v1, v2: v1 + v2)
    elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
    elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
    else:
        # numbers
        v = int(e)
    stack.push(v)

print stack.pop()