import scala.io.StdIn

/**
  * AOJ
  */
object Main {

  def main(args: Array[String]): Unit = {

    while(true){
      val line = StdIn.readLine()
      if(line == "0"){return}
      println(line.toCharArray.map(_.toString.toInt).sum)
    }
  }
}