import scala.io.StdIn._

object Main {
  def main(args: Array[String]): Unit = {
    def lines: Unit ={
      def loop(line: String): Unit ={
        if (line != "0") {
          println(line.split("").map(_.toInt).sum)
          loop(readLine())
        }
      }
      loop(readLine())
    }

    lines
  }
}