#!/usr/bin/env python3
import sys
class mystack:
  v = [0 for i in range(222)]
  t = 0

  def push(self,a):
    self.t += 1
    self.v[self.t] = a
  def pop(self):
    self.t -= 1
  def top(self):
    return self.v[self.t]
  def pr(self):
    for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
    sys.stdout.write('\n')

s = mystack()
l = sys.stdin.readline().split()

for i in l:
  if not i.isdigit():
    a = s.top()
    s.pop()
    b = s.top()
    s.pop()
    if i == '+':
      s.push(b+a)
    if i == '-':
      s.push(b-a)
    if i == '*':
      s.push(b*a)
  else:
    s.push(int(i))

print(s.top()) import sys sys class mystack:
  v = [0 for i in range(222)]
  t = 0

  def push(self,a):
    self.t += 1
    self.v[self.t] = a
  def pop(self):
    self.t -= 1
  def top(self):
    return self.v[self.t]
  def pr(self):
    for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
    sys.stdout.write('\n') mystack 0 for i in range(222) for i in range(222) i range(222) range 222 for i in range(222) 0 v = [0 for i in range(222)] v [0 for i in range(222)] t = 0 t 0 def push(self,a):
    self.t += 1
    self.v[self.t] = a
   push self.t += 1 self.t self t 1 self.v[self.t] = a self.v[self.t] self.v self v self.t self t a self self a a def pop(self):
    self.t -= 1
   pop self.t -= 1 self.t self t 1 self self def top(self):
    return self.v[self.t]
   top return self.v[self.t] self.v[self.t] self.v self v self.t self t self self def pr(self):
    for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
    sys.stdout.write('\n') pr for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
     i range(1, self.t+1) range 1 self.t+1 self.t self t 1 sys.stdout.write(self.v[i] + " ") sys.stdout.write sys.stdout sys stdout write self.v[i] + " " self.v[i] self.v self v i " " sys.stdout.write('\n') sys.stdout.write sys.stdout sys stdout write '\n' self self s = mystack() s mystack() mystack l = sys.stdin.readline().split() l sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for i in l:
  if not i.isdigit():
    a = s.top()
    s.pop()
    b = s.top()
    s.pop()
    if i == '+':
      s.push(b+a)
    if i == '-':
      s.push(b-a)
    if i == '*':
      s.push(b*a)
  else:
    s.push(int(i)) i l if not i.isdigit():
    a = s.top()
    s.pop()
    b = s.top()
    s.pop()
    if i == '+':
      s.push(b+a)
    if i == '-':
      s.push(b-a)
    if i == '*':
      s.push(b*a)
  else:
    s.push(int(i)) not i.isdigit() i.isdigit() i.isdigit i isdigit a = s.top() a s.top() s.top s top s.pop() s.pop s pop b = s.top() b s.top() s.top s top s.pop() s.pop s pop if i == '+':
      s.push(b+a)
     i == '+' i '+' s.push(b+a) s.push s push b+a b a if i == '-':
      s.push(b-a)
     i == '-' i '-' s.push(b-a) s.push s push b-a b a if i == '*':
      s.push(b*a)
   i == '*' i '*' s.push(b*a) s.push s push b*a b a s.push(int(i)) s.push s push int(i) int i print(s.top()) print s.top() s.top s top l = sys.stdin.readline().split() sys.stdin.readline().split() l b = s.top() s.top() b s = mystack() mystack() s a = s.top() s.top() a class mystack:
  v = [0 for i in range(222)]
  t = 0

  def push(self,a):
    self.t += 1
    self.v[self.t] = a
  def pop(self):
    self.t -= 1
  def top(self):
    return self.v[self.t]
  def pr(self):
    for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
    sys.stdout.write('\n') class mystack:
  v = [0 for i in range(222)]
  t = 0

  def push(self,a):
    self.t += 1
    self.v[self.t] = a
  def pop(self):
    self.t -= 1
  def top(self):
    return self.v[self.t]
  def pr(self):
    for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
    sys.stdout.write('\n') mystack
#!/usr/bin/env python3
import sys
class mystack:
  v = [0 for i in range(222)]
  t = 0

  def push(self,a):
    self.t += 1
    self.v[self.t] = a
  def pop(self):
    self.t -= 1
  def top(self):
    return self.v[self.t]
  def pr(self):
    for i in range(1, self.t+1):
      sys.stdout.write(self.v[i] + " ")
    sys.stdout.write('\n')

s = mystack()
l = sys.stdin.readline().split()

for i in l:
  if not i.isdigit():
    a = s.top()
    s.pop()
    b = s.top()
    s.pop()
    if i == '+':
      s.push(b+a)
    if i == '-':
      s.push(b-a)
    if i == '*':
      s.push(b*a)
  else:
    s.push(int(i))

print(s.top())