import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{

   int n,m,l;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   }


  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main{
  public static void main(String args[]) throws IOException{

   int n,m,l;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   }


  }
} Main public static void main(String args[]) throws IOException{

   int n,m,l;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   }


  } main {

   int n,m,l;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   }


  } int n n m m l; l BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   } true {

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   } String line = br.readLine(); line br.readLine() br.readLine br String[] token = line.split(""); token line.split("") line.split line "" if(line.equals("0")) break; line.equals("0") line.equals line "0" break; int sum = 0; sum 0 for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   } int i = 0; int i = 0; i 0 i < token.length i token.length token token.length i++ i++ i {
		   sum += Integer.parseInt( token[i] );
	   } {
		   sum += Integer.parseInt( token[i] );
	   } sum += Integer.parseInt( token[i] ) sum Integer.parseInt( token[i] ) Integer.parseInt Integer token[i] token i System.out.println(sum) System.out.println System.out System System.out sum String args[] args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{

   int n,m,l;
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


   while(true){

	   String line = br.readLine();
	   String[] token = line.split("");
	   if(line.equals("0")) break;
	   int sum = 0;
	   for(int i = 0; i < token.length;i++){
		   sum += Integer.parseInt( token[i] );
	   }

	   System.out.println(sum);

   }


  }
}