import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val stack = Stack<String>()
    stack.push(sc.next())
    while (true) {
        val input = sc.next()
        if (input == "=") break
        try {
            val a = Integer.parseInt(input)
            val op = stack.pop()
            val b = Integer.parseInt(stack.pop())
            stack.push(
                when (op) {
                    "+" -> b+a
                    "-" -> b-a
                    "*" -> b*a
                    else -> b/a
                }.toString()
            )
        }
        catch (e: NumberFormatException) {
            stack.push(input)
        }
    }
    println(stack.pop())
}
