# Aizu Problem ALDS_1_3_A: Stack
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


stack = []
for x in input().split():
    if x == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif x == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif x == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(x))

print(stack[0]) import sys, math, os sys math os PYDEV = os.environ.get('PYDEV') PYDEV os.environ.get('PYDEV') os.environ.get os.environ os environ get 'PYDEV' if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt") PYDEV=="True" PYDEV "True" sys.stdin = open("sample-input.txt", "rt") sys.stdin sys stdin open("sample-input.txt", "rt") open "sample-input.txt" "rt" stack = [] stack [] for x in input().split():
    if x == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif x == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif x == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(x)) x input().split() ().split () input split if x == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif x == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif x == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(x)) x == '+' x '+' b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop stack.append(a + b) stack.append stack append a + b a b elif x == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
     x == '-' x '-' b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop stack.append(a - b) stack.append stack append a - b a b elif x == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
     x == '*' x '*' b = stack.pop() b stack.pop() stack.pop stack pop a = stack.pop() a stack.pop() stack.pop stack pop stack.append(a * b) stack.append stack append a * b a b stack.append(int(x)) stack.append stack append int(x) int x print(stack[0]) print stack[0] stack 0 b = stack.pop() stack.pop() b a = stack.pop() stack.pop() a stack = [] [] stack b = stack.pop() stack.pop() b PYDEV = os.environ.get('PYDEV') os.environ.get('PYDEV') PYDEV a = stack.pop() stack.pop() a a = stack.pop() stack.pop() a b = stack.pop() stack.pop() b
# Aizu Problem ALDS_1_3_A: Stack
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


stack = []
for x in input().split():
    if x == '+':
        b = stack.pop()
        a = stack.pop()
        stack.append(a + b)
    elif x == '-':
        b = stack.pop()
        a = stack.pop()
        stack.append(a - b)
    elif x == '*':
        b = stack.pop()
        a = stack.pop()
        stack.append(a * b)
    else:
        stack.append(int(x))

print(stack[0])