var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var row = input.split('\n');
var result = [];
for(var i=0;i<row.length;i++){
    var x = row[i].split('').map(Number);
    if(x[0] === 0){
        break;
    }
    var total = x.reduce(function(a,b){return a+b;});
    result.push(total);
}
console.log(result.join('\n'));
