object Main extends App {
  val sc = new java.util.Scanner(System.in)
  execute(sc.next())

  def execute(in: String): Unit = {
    in match {
      case "0" => sc.close()
      case _ =>
        println(in.toList.map(_.toString).map(_.toLong).sum)
        execute(sc.next())
    }
  }
}