fun main(args: Array<String>) {
    while (true) {
        val inputString = readLine()!!
        if (inputString == "0") break
        println("${inputString.map { it.toString().toInt() }.sum()}")
    }
}

