object Main extends App {

  val input = Console.in.readLine.split(" ")
    
  val stk = (List[Int]() /: input) { (stk, sym) => sym match {
      case "+" => stk(1) + stk(0) :: (stk drop 2)
      case "-" => stk(1) - stk(0) :: (stk drop 2)
      case "*" => stk(1) * stk(0) :: (stk drop 2)
      case num => num.toInt :: stk
    }
  }
  println(stk.head)
}

