object Main {
  def main(args: Array[String]): Unit = {
    while(true) {
      val in = io.StdIn.readLine()
      if(in.equals("0")) System.exit(0)
      println(in.toList.map(_.toInt - '0'.toInt).sum)
    }
  }
}

