'use strict'

const main = arg => {
    var input = arg.trim().split("\n");
    const endIndex = input.indexOf("0");
    input = input.slice(0, endIndex);
    const result = [];

    input.forEach(str => {
        const sum = str.split("").map(num => parseInt(num ,10)).reduce((a,b) => a + b);
        result.push(sum);
    });
    
    console.log(result.join("\n"));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
