import scala.util.control.Exception._
import java.util.InputMismatchException

object Main {
  def calc(n: Int, op: String, m: Int): Int = {
    op match {
      case "+" => m + n
      case "-" => m - n
      case _ => m * n
    }
  }

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val st = scala.collection.mutable.Stack[Int]()

    st.push(sc.nextInt)
    st.push(sc.nextInt)
    while(sc.hasNext) {
      val n = sc.next
      n match {
        case "+" | "-" | "*" => st.push(calc(st.pop, n, st.pop))
        case x => st.push(x.toInt)
      }
    }
    println(st.pop)
  }
}

