import scala.io.StdIn

object Main {
  def main(args: Array[String]) {
    var arr: Array[String] = StdIn.readLine().split(" ")
    var stack: Array[String] = Array.empty
    for(v <- arr) {
      stack = calc(stack, v)
    }
    println(stack(0))
  }

  def calc(stack: Array[String], v: String): Array[String] = {
    var ret = stack.clone()
    if(v != "+" && v != "-" && v != "*") return ret :+ v

    val y = ret.last.toInt
    ret = ret.dropRight(1)
    val x = ret.last.toInt
    ret = ret.dropRight(1)

    if(v == "+") {
      return ret :+ (x + y).toString
    } else if(v == "-") {
      return ret :+ (x - y).toString
    } else {
      return ret :+ (x * y).toString
    }
  }
}