var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");
  var i = 0;
  while (true) {
    var x = input[i];
    if (x == "0") {
      break;
    }

    var sum = 0;
    for (j = 0; j < x.length; j++) {
      sum += parseInt(x[j], 10);
    }

    console.log(sum)
    i++;
  }
});