import scala.io.StdIn.readLine

object Main extends App {
  val lines = Iterator.continually(readLine()).takeWhile { _ != "0" }

  val results = for {
    line  <- lines
    digits = line.map { _.asDigit }
  } yield digits.sum

  results.foreach(println)
}

