import collection.mutable.Stack
import java.util._
 
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val str = sc.nextLine.split(" ")
    val stack = Stack[Int]()
 
    str foreach {
      case "*" => stack.push(stack.pop * stack.pop)
      case "+" => stack.push(stack.pop + stack.pop)
      case "-" => stack.push(- stack.pop + stack.pop)
      case df => stack.push(df.toInt)
    }
    println(stack.pop)
  }
}