object SumOfNumbers {
  val sc = new java.util.Scanner(System.in)


  def run {
    var l = sc.nextLine()
    while (l != "0") {
      println(sum(l))
      l = sc.nextLine()
    }
  }
  def sum(line:String): Int = {
    val a =line.toCharArray

    val b = a.map( n => n.asDigit)

    b.sum

  }

}


object Main extends App{
 SumOfNumbers.run
}