import scala.util.Try

object Main {

  def calc(e: String, i: Long, j: Long): Long =
    e match {
      case "+" => j + i
      case "-" => j - i
      case "*" => j * i
      case _ => throw new IllegalArgumentException()
    }

  def main(args: Array[String]) : Unit = {
    val stack: Seq[Long] = scala.io.StdIn.readLine().split(" ")
                           .foldLeft(List[Long]()) { (list, elem) =>
                             Try(elem.toLong).getOrElse(elem) match {
                               case e: Long => e +: list
                               case e: String => calc(e, list(0), list(1)) +: list.drop(2)
                               case _ => throw new IllegalArgumentException()
                             }
                           }
    println(stack.head)
  }
}

