function main(input) {
  let args = input.split("\n");
  let n = args.length;

  for (let i = 0; i < n; i++) {
    if (args[i] === "0") {
      break;
    }
    let ret = 0;
    for (let j = 0; j < args[i].length; j++) {
      ret += Number(args[i][j]);
    }
    console.log(ret);
  }
}

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