import scala.io.StdIn._

object Main extends App {

  def poland(a: Array[String], stack: Stack) {
    a.foreach{
      case x if (x == "+") => stack.push(stack.pop() + stack.pop())
      case x if (x == "-") => stack.push((stack.pop() - stack.pop()) * -1)
      case x if (x == "*") => stack.push(stack.pop() * stack.pop())
      case x => stack.push(x.toInt)
    }
  }

  val stack = new Stack(Array[Int](0), 0)
  val a = readLine.split(" ").toArray
  poland(a, stack)
  println(stack.pop())
}

class Stack(var a: Array[Int], var top: Int) {
  def push(x: Int) {
    a = a:+x
    top += 1
  }
  def pop() = {
    val x = a(top)
    top -= 1
    a = a.init
    x
  }
}
