fun main(args: Array<String>){
	Sum_of_Numbers()
}
fun Sum_of_Numbers(){
	var i=0
	while(i<10000){
		var sum = 0
		val n = readLine()!!
		if(n=="0")break
		for(j in 0..n.length-1){
			sum += n.substring(j,j+1).toInt()
		}
		println(sum)
		i++
	}
}
