var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( "\n" );
  
  var output = [];
  for( var i=0; i<data.length; i++ ) {
      var nums = data[i].split( '' ).map( Number );
      if( 0 == nums[0] ) { break; }
      
      var sum = 0;
      for( var j=0; j<nums.length; j++ ) {
        sum += nums[j];
      }
      output.push( sum );
  }
  console.log( output.join( '\n' ) );
});
 