"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
123
55
1000
0
*/

reader.on('close', () => {
    for (var line of lines) {
	if (line==="0") {
	    break;
	}
	console.log(aux(line));
    }
});

function aux(s)
{
    return(s.split('').map(Number).reduce((s,x)=>{return s+x}))
}
