/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_B&lang=jp
  * Character - Sum of Numbers
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).takeWhile(_ != "0")
      .map(_.map(_.toString.toInt).sum)
      .foreach(println)
  }
}