object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .takeWhile(_ != "0")
      .map(_.foldLeft(0) { case (acc, c) => acc + (c - '0') })
      .foreach(println)
  }
}