object Main extends App {
  import scala.io.StdIn._

  solve
  def solve: Unit = {
    val expression = readLine
    if (expression == null) return
    val calculator = Calculator()
    for (button ← expression.trim){
      calculator.push(button)
    }
    println(calculator.display)
    solve
  }
  case class Calculator(r1: Register = new Register, r2: Register = new Register, var r3: Operator = Null) {
    def push(button: Char): Unit = {
      button match {
        case d if d.isDigit ⇒ r2.addDigit(d)
        case o ⇒
          consumeOperator()
          o match {
            case '=' ⇒ r3 = Null
            case '+' ⇒ r3 = Add
            case '-' ⇒ r3 = Sub
            case '*' ⇒ r3 = Mul
            case _ ⇒ ???
          }
      }
    }
    private[this] def consumeOperator(): Unit = {
      r3 match {
        case Null ⇒ operate((_, b) ⇒ b)
        case Add ⇒ operate(_+_)
        case Sub ⇒ operate(_-_)
        case Mul ⇒ operate(_*_)
      }
    }
    private[this] def operate(op: (Int, Int) ⇒ Int): Unit = {
      r1.replace(r1.value.flatMap(a ⇒ r2.value.map(b ⇒ op(a, b))).filter(n ⇒ 0 <= n && n < 10000))
      r2.flush()
    }
    def display: String = {
      r1.value match {
        case None ⇒ "E"
        case Some(value) ⇒ value.toString
      }
    }
  }
  class Register{
    private[this] var acc: Option[Int] = Some(0)
    private[this] def validate(): Unit = {
      acc = acc.filter(n ⇒ 0 <= n && n < 10000)
    }
    def addDigit(digit: Char): Unit = {
      acc = acc.map(_ * 10 + digit.asDigit)
      validate()
    }
    def flush(): Unit = {
      acc = acc.map(_ ⇒ 0)
    }
    def copyFrom(register: Register): Unit = {
      acc = acc.flatMap(_ ⇒ register.value)
    }
    def replace(newValue: Option[Int]): Unit = {
      acc = acc.flatMap(_ ⇒ newValue)
      validate()
    }
    def value: Option[Int] = {
      validate()
      acc
    }
    override def toString: String = s"Register(${acc.getOrElse("E")})"
  }
  sealed trait Value
  case class Valid(value: Int) extends Value
  case object E extends Value
  sealed trait Operator
  case object Null extends Operator
  case object Add extends Operator
  case object Sub extends Operator
  case object Mul extends Operator
  implicit class Scope[T](val value: T) extends AnyVal{
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}
