import java.util.Scanner
import scala.collection.JavaConverters.asScalaIterator
    
object Main extends App {
    
  val sc = new Scanner(Console.in)

  val stk = (List[Int]() /: asScalaIterator(sc)) { (stk, sym) =>
    sym match {
      case "+" => stk(1) + stk(0) :: (stk drop 2)
      case "-" => stk(1) - stk(0) :: (stk drop 2)
      case "*" => stk(1) * stk(0) :: (stk drop 2)
      case num => num.toInt :: stk
    }
  }
  println(stk.head)
}

