import scala.util.control.Breaks
object Main extends App {
  val b = new Breaks
  b.breakable {
    while(true) {
      val x = readLine
      if (x == "0") b.break()
      println(x.map(_.toString.toInt).sum)
    }
  }
}
