process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  for (let i = 0; i < lines.length; i++) {
    let n = lines[i];
    if (n === "0") break;
    console.log(
      n
        .split("")
        .map(Number)
        .reduce((a, b) => a + b)
    );
  }
});

