def init():
  global top
  top = 0

def isEmpty():
  global top
  return top == 0

def isFull():
  global top, MAX
  return top >= MAX

def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1


def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top]


def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2

data = list(map(str, input().split()))
top = 0
MAX = 100
s = [0 for i in range(MAX)]
for i in data:
  if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i)
print(s[0])
 def init():
  global top
  top = 0 init global top top = 0 top 0 def isEmpty():
  global top
  return top == 0 isEmpty global top return top == 0 top == 0 top 0 def isFull():
  global top, MAX
  return top >= MAX isFull global top, MAX return top >= MAX top >= MAX top MAX def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1 push global top, s if isFull():
    return False
   isFull() isFull return False False s[top] = x s[top] s top x top += 1 top 1 x x def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top] pop global top, s if isEmpty():
    return False
   isEmpty() isEmpty return False False top -= 1 top 1 return s[top] s[top] s top def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2 calc if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2 op == '+' op '+' return i_1 + i_2 i_1 + i_2 i_1 i_2 elif op == '-':
    return i_1 - i_2
   op == '-' op '-' return i_1 - i_2 i_1 - i_2 i_1 i_2 return i_1 * i_2 i_1 * i_2 i_1 i_2 i_1 i_1 i_2 i_2 op op data = list(map(str, input().split())) data list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split top = 0 top 0 MAX = 100 MAX 100 0 for i in range(MAX) for i in range(MAX) i range(MAX) range MAX for i in range(MAX) 0 s = [0 for i in range(MAX)] s [0 for i in range(MAX)] for i in data:
  if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i) i data if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i) i == '+' or i == '*' or i == '-' i == '+' or i == '*' i == '+' i '+' i == '*' i '*' i == '-' i '-' a = pop() a pop() pop b = pop() b pop() pop push(calc(int(b), int(a), i)) push calc(int(b), int(a), i) calc int(b) int b int(a) int a i push(i) push i print(s[0]) print s[0] s 0 top = 0 0 top def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top] def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top] pop MAX = 100 100 MAX b = pop() pop() b def init():
  global top
  top = 0 def init():
  global top
  top = 0 init def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1 def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1 push def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2 def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2 calc data = list(map(str, input().split())) list(map(str, input().split())) data def isEmpty():
  global top
  return top == 0 def isEmpty():
  global top
  return top == 0 isEmpty a = pop() pop() a def isFull():
  global top, MAX
  return top >= MAX def isFull():
  global top, MAX
  return top >= MAX isFull s = [0 for i in range(MAX)] [0 for i in range(MAX)] s
def init():
  global top
  top = 0

def isEmpty():
  global top
  return top == 0

def isFull():
  global top, MAX
  return top >= MAX

def push(x):
  global top, s
  if isFull():
    return False
  s[top] = x
  top += 1


def pop():
  global top, s
  if isEmpty():
    return False
  top -= 1
  return s[top]


def calc(i_1, i_2, op):
  if op == '+':
    return i_1 + i_2
  elif op == '-':
    return i_1 - i_2
  else:
    return i_1 * i_2

data = list(map(str, input().split()))
top = 0
MAX = 100
s = [0 for i in range(MAX)]
for i in data:
  if i == '+' or i == '*' or i == '-':
    a = pop()
    b = pop()
    push(calc(int(b), int(a), i))
  else:
    push(i)
print(s[0])

