//line = require('fs').readFileSync('tmp', 'ascii').split('\r\n'); // win
line = require('fs').readFileSync('/dev/stdin', 'ascii').split('\n'); // linux

res = [];
for (i in line) {
	str = line[i];
	if (str === '0') break;
	sum = 0;
	for (j in str) sum += parseInt(str[j]);
	res.push(sum);
}
console.log(res.join('\n'));