import collection.mutable.Stack


object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val symbols = sc.nextLine.split("""\s+""")
    val stack = Stack[Int]()

    symbols foreach {
      case "*" => stack.push(stack.pop * stack.pop)
      case "+" => stack.push(stack.pop + stack.pop)
      case "-" => stack.push(- stack.pop + stack.pop)
      case num => stack.push(num.toInt)
    }

    println(stack.pop)
  }
}