"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	lines.some(function(line){
		if(line == "0") return true;
		console.log(line.split("").reduce(function(a,b){return a+ +b;}, 0));
	});
}