object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val inputs = Iterator.continually(scanner.next())

  val outputs = inputs.takeWhile(_ != "0")
    .map(_.foldLeft(0)(_ + _.toInt - '0'))

  outputs.foreach(println)
}