import sys

def isEmpty(S):
  if len(S) == 0:
    return True
  
def isFull(S):
  if len(S) >= 101:
    return True

def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
  
def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k

S = []
top = -1

x = sys.stdin.readline().strip()
x_list = x.split(" ")

for i in range(0, len(x_list)):
  if x_list[i] == '*':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a * b)
    top += 1
    
  elif x_list[i] == '+':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a + b)
    top += 1
    
  elif x_list[i] == '-':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(b - a)
    top += 1
    
  else:
    push(x_list[i])
    top += 1
    
a = int(pop(top))
print a import sys sys def isEmpty(S):
  if len(S) == 0:
    return True
   isEmpty if len(S) == 0:
    return True
   len(S) == 0 len(S) len S 0 return True True S S def isFull(S):
  if len(S) >= 101:
    return True isFull if len(S) >= 101:
    return True len(S) >= 101 len(S) len S 101 return True True S S def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
   push if isFull(S):
    print 'Error'
   isFull(S) isFull S print S.append(x) S.append S append x x x def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k pop if isEmpty(S):
    print 'error'
   isEmpty(S) isEmpty S print k = S[top] k S[top] S top S.pop() S.pop S pop return k k top top S = [] S [] top = -1 top -1 x = sys.stdin.readline().strip() x sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip x_list = x.split(" ") x_list x.split(" ") x.split x split " " for i in range(0, len(x_list)):
  if x_list[i] == '*':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a * b)
    top += 1
    
  elif x_list[i] == '+':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a + b)
    top += 1
    
  elif x_list[i] == '-':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(b - a)
    top += 1
    
  else:
    push(x_list[i])
    top += 1
     i range(0, len(x_list)) range 0 len(x_list) len x_list if x_list[i] == '*':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a * b)
    top += 1
    
  elif x_list[i] == '+':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a + b)
    top += 1
    
  elif x_list[i] == '-':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(b - a)
    top += 1
    
  else:
    push(x_list[i])
    top += 1
     x_list[i] == '*' x_list[i] x_list i '*' a = int(pop(top)) a int(pop(top)) int pop(top) pop top top -= 1 top 1 b = int(pop(top)) b int(pop(top)) int pop(top) pop top top -= 1 top 1 push(a * b) push a * b a b top += 1 top 1 elif x_list[i] == '+':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a + b)
    top += 1
    
   x_list[i] == '+' x_list[i] x_list i '+' a = int(pop(top)) a int(pop(top)) int pop(top) pop top top -= 1 top 1 b = int(pop(top)) b int(pop(top)) int pop(top) pop top top -= 1 top 1 push(a + b) push a + b a b top += 1 top 1 elif x_list[i] == '-':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(b - a)
    top += 1
    
   x_list[i] == '-' x_list[i] x_list i '-' a = int(pop(top)) a int(pop(top)) int pop(top) pop top top -= 1 top 1 b = int(pop(top)) b int(pop(top)) int pop(top) pop top top -= 1 top 1 push(b - a) push b - a b a top += 1 top 1 push(x_list[i]) push x_list[i] x_list i top += 1 top 1 a = int(pop(top)) a int(pop(top)) int pop(top) pop top print def isFull(S):
  if len(S) >= 101:
    return True def isFull(S):
  if len(S) >= 101:
    return True isFull x_list = x.split(" ") x.split(" ") x_list top = -1 -1 top top -= 1 1 top top += 1 1 top b = int(pop(top)) int(pop(top)) b a = int(pop(top)) int(pop(top)) a b = int(pop(top)) int(pop(top)) b a = int(pop(top)) int(pop(top)) a S = [] [] S top -= 1 1 top top += 1 1 top top -= 1 1 top x = sys.stdin.readline().strip() sys.stdin.readline().strip() x top += 1 1 top a = int(pop(top)) int(pop(top)) a top -= 1 1 top top -= 1 1 top def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k pop top += 1 1 top def isEmpty(S):
  if len(S) == 0:
    return True
   def isEmpty(S):
  if len(S) == 0:
    return True
   isEmpty a = int(pop(top)) int(pop(top)) a top -= 1 1 top b = int(pop(top)) int(pop(top)) b def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
   def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
   push
import sys

def isEmpty(S):
  if len(S) == 0:
    return True
  
def isFull(S):
  if len(S) >= 101:
    return True

def push(x):
  if isFull(S):
    print 'Error'
  S.append(x)
  
def pop(top):
  if isEmpty(S):
    print 'error'
  k = S[top]
  S.pop()
  return k

S = []
top = -1

x = sys.stdin.readline().strip()
x_list = x.split(" ")

for i in range(0, len(x_list)):
  if x_list[i] == '*':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a * b)
    top += 1
    
  elif x_list[i] == '+':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(a + b)
    top += 1
    
  elif x_list[i] == '-':
    a = int(pop(top))
    top -= 1
    b = int(pop(top))
    top -= 1
    push(b - a)
    top += 1
    
  else:
    push(x_list[i])
    top += 1
    
a = int(pop(top))
print a