import scala.io.StdIn.readLine;
object Main {
    def main(args: Array[String]): Unit = {
        val ret = readLine.split(" ").foldLeft(List[Long]()) { (stack, i) =>
            if (i  == "+") stack match {
                case a :: b :: rest => b + a :: rest;
                case _ => stack;
            } else if (i == "-") stack match {
                case a :: b :: rest => b - a :: rest;
                case _ => stack;
            } else if (i == "*") stack match {
                case a :: b :: rest => b * a :: rest;
                case _ => stack;
            } else i.toLong :: stack;
        }
        println(ret.head);
    }
}
