import scala.collection.mutable.Stack


object Main {
  def main(args: Array[String]) = {
    val lst = io.StdIn.readLine.split(" ")

    val num = "\\d+".r

    // println(lst.toList)

    val stack = new Stack[Int]

    lst map {
      case "+" =>
        val lft = stack.pop
        val rgt = stack.pop
        stack push rgt + lft
      case "-" =>
        val lft = stack.pop
        val rgt = stack.pop
        stack push rgt - lft
      case "*" =>
        val lft = stack.pop
        val rgt = stack.pop
        stack push rgt * lft
      case other => stack push other.toInt
    }

    println(stack.pop)
  }
}

