import scala.io.StdIn.readLine

object Main {
  def revP(l:List[String],stack:List[Int]):Int =  {
    l match {
      case Nil => stack(0)
      case hd::tl =>
        val stack2 =
          if(hd!="+" && hd!="-" && hd!="*") hd.toInt::stack
          else {
            val x::y::tail = stack
            if(hd=="+") (y+x)::tail
            else if(hd=="-") (y-x)::tail
            else if(hd=="*") (y*x)::tail
            else Nil
          }
        revP(tl,stack2)
    }
  }

  def main(args:Array[String]) = {
    val l = readLine.split(" ").toList
    println(revP(l,Nil))
  }
}