# coding: UTF-8
from collections import deque
operators = {'+','*','-'}

def operate(L,R,C):
  if C == '+':
    return L + R
  elif C == '*':
    return L * R
  else: #<=>if C == '-'
    return L - R

raw = input().split()
stack = deque()
for C in raw:
  if C in operators:
    R = stack.pop()
    L = stack.pop()
    stack.append(operate(L,R,C))
  else:
    stack.append(int(C))
print(stack.pop())
 from collections import deque operators = {'+','*','-'} operators {'+','*','-'} def operate(L,R,C):
  if C == '+':
    return L + R
  elif C == '*':
    return L * R
  else: #<=>if C == '-'
    return L - R operate if C == '+':
    return L + R
  elif C == '*':
    return L * R
  else: #<=>if C == '-'
    return L - R C == '+' C '+' return L + R L + R L R elif C == '*':
    return L * R
   C == '*' C '*' return L * R L * R L R return L - R L - R L R L L R R C C raw = input().split() raw input().split() ().split () input split stack = deque() stack deque() deque for C in raw:
  if C in operators:
    R = stack.pop()
    L = stack.pop()
    stack.append(operate(L,R,C))
  else:
    stack.append(int(C)) C raw if C in operators:
    R = stack.pop()
    L = stack.pop()
    stack.append(operate(L,R,C))
  else:
    stack.append(int(C)) C in operators C operators R = stack.pop() R stack.pop() stack.pop stack pop L = stack.pop() L stack.pop() stack.pop stack pop stack.append(operate(L,R,C)) stack.append stack append operate(L,R,C) operate L R C stack.append(int(C)) stack.append stack append int(C) int C print(stack.pop()) print stack.pop() stack.pop stack pop L = stack.pop() stack.pop() L stack = deque() deque() stack raw = input().split() input().split() raw operators = {'+','*','-'} {'+','*','-'} operators def operate(L,R,C):
  if C == '+':
    return L + R
  elif C == '*':
    return L * R
  else: #<=>if C == '-'
    return L - R def operate(L,R,C):
  if C == '+':
    return L + R
  elif C == '*':
    return L * R
  else: #<=>if C == '-'
    return L - R operate R = stack.pop() stack.pop() R
# coding: UTF-8
from collections import deque
operators = {'+','*','-'}

def operate(L,R,C):
  if C == '+':
    return L + R
  elif C == '*':
    return L * R
  else: #<=>if C == '-'
    return L - R

raw = input().split()
stack = deque()
for C in raw:
  if C in operators:
    R = stack.pop()
    L = stack.pop()
    stack.append(operate(L,R,C))
  else:
    stack.append(int(C))
print(stack.pop())

