import scala.io.StdIn._
object Main extends App {
  readLine.trim match {
    case Expression(e) ⇒
      println(math.max(e.execute(Operator(Plus, Minus, Times), Operator(Plus), Operator(Plus)), Array(Operator(Plus), Operator(Minus), Operator(Times)).permutations.flatMap{case Array(p, n, s) ⇒ Array(e.execute(p, n, s), e.execute(p + n, n, s), e.execute(p, n + s, s))}.max))
    case _ ⇒ ???
  }
}
object Expression {
  def unapply(arg: String): Option[Expression] = {
    arg.toList match {
      case f Formula Nil ⇒ Some(Expression(f))
      case _ ⇒ ???
    }
  }
  object Num {
    def unapply(arg: List[Char]): Option[(Number, List[Char])] = {
      arg.span(_.isDigit) match {
        case (Nil, _) ⇒ None
        case (h, t) ⇒ Some(Number(h.foldLeft(0L){case (acc, r) ⇒ acc * 10 + r.asDigit}), t)
      }
    }
  }
  object Formula {
    def unapply(arg: List[Char]): Option[(Expr, List[Char])] = {
      arg match {
        case n Num r ⇒
          r match {
            case '+'::(m Formula rest) ⇒ Some(Expr(n, Succ(Plus, m)), rest)
            case '-'::(m Formula rest) ⇒ Some(Expr(n, Succ(Minus, m)), rest)
            case '*'::(m Formula rest) ⇒ Some(Expr(n, Succ(Times, m)), rest)
            case _ ⇒ Some((Expr(n, End), r))
          }
        case '('::(f Formula ')'::r) ⇒
          r match {
            case '+'::(m Formula rest) ⇒ Some(Expr(Bracket(Expression(f)), Succ(Plus, m)), rest)
            case '-'::(m Formula rest) ⇒ Some(Expr(Bracket(Expression(f)), Succ(Minus, m)), rest)
            case '*'::(m Formula rest) ⇒ Some(Expr(Bracket(Expression(f)), Succ(Times, m)), rest)
            case _ ⇒ Some((Expr(Bracket(Expression(f)), End), r))
          }
        case _ ⇒ None
      }
    }
  }
}

object Operator {
  def apply(operator: BiOp*): Operator = new Operator(operator)
}
class Operator(val operator: Seq[BiOp]) {
  def unapply(op: BiOp): Option[(Long ⇒ Long ⇒ Long)] = {
    Some(op).filter(operator.contains)
  }
  def +(that: Operator): Operator = new Operator(operator ++ that.operator)
}
case class Expression(expr: Expr) {
  def execute(priOp: Operator, norOp: Operator, subOp: Operator): Long = {
    expr.flatten(priOp, norOp, subOp).calculate(priOp, norOp, subOp)
  }
}
case class FExpr(head: Long, tail: FExprT) {
  def calculate(priOp: Operator, norOp: Operator, subOp: Operator): Long = consume(consume(consume(this, priOp), norOp), subOp) match {
    case head FExpr FEnd ⇒ head
    case _ ⇒ ???
  }
  private def consume(expr: FExpr, operator: Operator): FExpr = {
    expr match {
      case left FExpr (operator(op) FSucc (right FExpr rest)) ⇒ consume(FExpr(op(left)(right), rest), operator)
      case head FExpr (op FSucc rest) ⇒ FExpr(head, FSucc(op, consume(rest, operator)))
      case _ ⇒ expr
    }
  }
}
sealed trait FExprT
case class FSucc(op: BiOp, tail: FExpr) extends FExprT
case object FEnd extends FExprT

case class Expr(head: Factor, tail: ExprT) {
  def flatten(priOp: Operator, norOp: Operator, subOp: Operator): FExpr = {
    head match {
      case Bracket(expr) ⇒ FExpr(expr.execute(priOp, norOp, subOp), tail.flatten(priOp: Operator, norOp: Operator, subOp: Operator))
      case Number(value) ⇒ FExpr(value, tail.flatten(priOp: Operator, norOp: Operator, subOp: Operator))
    }
  }
}
sealed trait ExprT {
  def flatten(priOp: Operator, norOp: Operator, subOp: Operator): FExprT = {
    this match {
      case End ⇒ FEnd
      case op Succ tail ⇒ FSucc(op, tail.flatten(priOp, norOp, subOp))
    }
  }
}
case class Succ(op: BiOp, tail: Expr) extends ExprT
case object End extends ExprT

sealed trait Factor
case class Bracket(expr: Expression) extends Factor
case class Number(value: Long) extends Factor

sealed trait BiOp extends (Long ⇒ Long ⇒ Long)
case object Plus extends BiOp {
  override def apply(v1: Long): Long ⇒ Long = v1.+
}
case object Minus extends BiOp {
  override def apply(v1: Long): Long ⇒ Long = v1.-
}
case object Times extends BiOp  {
  override def apply(v1: Long): Long ⇒ Long = v1.*
}



Measured memory_bytes: 45140