import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val line = scanner.nextLine()
    val stack = Stack<Int>()
    for (s in line.split(" ")) {
        when(s) {
            "+" -> {
                val a = stack.pop()
                val b = stack.pop()
                stack.push(b + a)
            }
            "-" -> {
                val a = stack.pop()
                val b = stack.pop()
                stack.push(b - a)
            }
            "*" -> {
                val a = stack.pop()
                val b = stack.pop()
                stack.push(b * a)
            }
            else -> {
                stack.push(s.toInt())
            }
        }
    }
    println(stack.pop())
}

