def ALDS1_3A():
  stk, RPexp = [], list(input().split())
  for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
  print(stk.pop())

if __name__ == '__main__':
    ALDS1_3A() def ALDS1_3A():
  stk, RPexp = [], list(input().split())
  for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
  print(stk.pop()) ALDS1_3A stk, RPexp = [], list(input().split()) stk [] RPexp list(input().split()) list input().split() ().split () input split for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
   v RPexp if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
   v in '+-*' v '+-*' n2, n1 = stk.pop(), stk.pop() n2 stk.pop() stk.pop stk pop n1 stk.pop() stk.pop stk pop stk.append(str(eval(n1+v+n2))) stk.append stk append str(eval(n1+v+n2)) str eval(n1+v+n2) eval n1+v+n2 n1+v n1 v n2 stk.append(v) stk.append stk append v print(stk.pop()) print stk.pop() stk.pop stk pop if __name__ == '__main__':
    ALDS1_3A() __name__ == '__main__' __name__ '__main__' ALDS1_3A() ALDS1_3A def ALDS1_3A():
  stk, RPexp = [], list(input().split())
  for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
  print(stk.pop()) def ALDS1_3A():
  stk, RPexp = [], list(input().split())
  for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
  print(stk.pop()) ALDS1_3A
def ALDS1_3A():
  stk, RPexp = [], list(input().split())
  for v in RPexp:
      if v in '+-*':
          n2, n1 = stk.pop(), stk.pop()
          stk.append(str(eval(n1+v+n2)))
      else:
          stk.append(v)
  print(stk.pop())

if __name__ == '__main__':
    ALDS1_3A()