import io.Source.stdin

/**
  * AOJ
  */
object Main {

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

    for(line <- stdin.getLines()){
      if(line == "0"){return}
      println(line.map(_.toString.toInt).sum)
    }
  }
}