import java.util.ArrayDeque

fun main(args: Array<String>){
    val  ss = readLine()!!.split(" ")
    val stack = ArrayDeque<Int>()
    for (s in ss){
        if (s == "+"){ stack.addLast(stack.removeLast() + stack.removeLast() ) }
        else if (s == "-"){ stack.addLast(-stack.removeLast() + stack.removeLast() ) }
        else if (s == "*"){ stack.addLast(stack.removeLast() * stack.removeLast() ) }
        else if (s == "/"){ stack.addLast(stack.removeLast() / stack.removeLast() ) }
        else stack.addLast(s.toInt())
    }
    println(stack.removeLast())
}

