import scala.io.StdIn._
object Main extends App {
  println(
    readLine.trim.split(' ').foldLeft(Nil: List[Int]){
      case (stack, d) if d.forall(_.isDigit) ⇒ d.toInt::stack
      case (a::b::rest, "+") ⇒ b + a :: rest
      case (a::b::rest, "-") ⇒ b - a :: rest
      case (a::b::rest, "*") ⇒ b * a :: rest
    }.head
  )
}

