fun main() = println(
    generateSequence(::readLine)
        .map { it.split(" ").filter(String::isNotEmpty) }
        .toList()
        .let {
            it.last().mapIndexed { index, operation ->
                it
                    .dropLast(1)
                    .map { it[index].toLong() }
                    .reduce(if (operation == "+") Long::plus else Long::times)
            }.sum()
        }
)