function main(input){
    let nums = input.split("\n");
    let i=0;
    while(nums[i]!=="0"){
        let sum=0;
        while(nums[i].length>0){
            let char = nums[i].slice(-1);
            nums[i] = nums[i].slice(0,-1);
            sum+= parseInt(char);
        }
        console.log(sum);
        i++;
    }
    
    
}


main(require("fs").readFileSync("/dev/stdin","utf-8"));
