import java.util.*

fun main(args: Array<String>) {
    val xs = readLine()!!.split(' ')
    val stack: Deque<Int> = ArrayDeque()

    for (x in xs) {
        when(x) {
            "+" -> stack.push(stack.pop() + stack.pop())
            "-" -> stack.push(-stack.pop() + stack.pop())
            "*" -> stack.push(stack.pop() * stack.pop())
            else -> stack.push(x.toInt())
        }
    }

    println(stack.pop())
}
