var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
if(Arr[i]==="0")break;
var arr=(Arr[i]+"").split("").map(Number);
var sum=arr.reduce(function(a,b){return a+b;});
console.log(sum);
}