fun main(args: Array<String>) {
    while (true) {
        val x = readLine()!!
        val digits = x.length
        if (x == "0") break

        var sum = 0
        for (i in 0 until digits) {
            val number: Int = x.substring(i, i + 1).toInt()
            sum += number
        }
        println(sum)

    }
}
