import scala.io.Source.stdin

object Main {
  def main(args: Array[String]) {
    stdin.getLines.takeWhile(_ != "0").foreach {
      line => {
        val sum = line.map(_.asDigit).foldLeft(0)(_ + _)
        println(sum)
      }
    }
  }
}

