import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)
    val data = mutableListOf<String>() 
    
    while(true){	
	    data.add(cin.nextLine())
	    if(data[data.lastIndex] == "0"){
	        data.removeAll{it == "0"}
	        break
	    }
    }

    for(i in data.indices){
        var result:Int = 0
	    for(j in data[i].indices){ 
    	    result += data[i][j].toString().toInt()
	    }
        println(result)
    }
}
