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

  def execute(in: Int): Unit = {
    in match {
      case 0 => sc.close()
      case _ =>
        println(in.toString.toList.map(_.toString).map(_.toInt).sum)
        execute(sc.nextInt())
    }
  }
}