import java.util.Stack

fun main(args: Array<String>) {
    //val n = readLine()!!.toInt()
    val list: List<String> = readLine()!!.split(" ").map { it.toString() }
    val calc: Stack<Int> = Stack()
    var first :Int
    var second:Int
    list.forEach{ i ->
        if (i =="+")
        {
            second = calc.pop().toInt()
            first = calc.pop().toInt()
            calc.push(first+ second)
        }
        else if(i=="-")
        {
            second = calc.pop().toInt()
            first = calc.pop().toInt()
            calc.push(first - second)
        }
        else if (i=="*")
        {
            second = calc.pop().toInt()
            first = calc.pop().toInt()
            calc.push(first * second)
        }
        else
        {
            calc.push(i.toInt())
        }
    }
    println(calc.pop())
}
