function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length; i++) {
        tmp = input[i].split("")
        if (input[i] === '0') {
            break
        }
        var sum = 0
        for (j=0; j < tmp.length; j++) {
            var x = parseInt(tmp[j])
            sum += x
        }
        console.log(sum)
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

