import scala.io.StdIn object Main { def parsing(j: Int, s: String): Int = { for (i <- (0 to j).reverse) { s(i - 1) match { case '+' => return parsing(i - 1, s) * s.slice(i, j).toInt case '*' => return parsing(i - 1, s) + s.slice(i, j).toInt case '#' => return s.slice(i, j).toInt case _ => } } return -1 } def main(args: Array[String]): Unit = { val s = "#" + StdIn.readLine println(parsing(s.length, s)) } }