import java.util.*

fun main(args: Array<String>) {
    val input = readLine()!!.split(" ")
    val stack = ArrayDeque<Int>()
    for (s in input) {
        when(s) {
            "+" -> {
                val temp = stack.pop() + stack.pop()
                stack.push(temp)
            }
            "-" -> {
                val temp = - stack.pop() + stack.pop()
                stack.push(temp)
            }
            "*" -> {
                val temp = stack.pop() * stack.pop()
                stack.push(temp)
            }
            "/" -> {
                val temp = stack.pop() / stack.pop()
                stack.push(temp)
            }
            else -> stack.push(s.toInt())
        }
    }

    println(stack.pop())
}
