import java.util.Scanner;
//import java.io.*;

 class Main {
    public static void main(String[] args){ 
    	Scanner scan = new Scanner(System.in);
    	   	                                                 
    	String str;
    	
    	while(true){
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	}  	
     }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args){ 
    	Scanner scan = new Scanner(System.in);
    	   	                                                 
    	String str;
    	
    	while(true){
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	}  	
     }
} Main public static void main(String[] args){ 
    	Scanner scan = new Scanner(System.in);
    	   	                                                 
    	String str;
    	
    	while(true){
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	}  	
     } main { 
    	Scanner scan = new Scanner(System.in);
    	   	                                                 
    	String str;
    	
    	while(true){
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	}  	
     } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String str; str while(true){
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	} true {
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	} str = scan.next() str scan.next() scan.next scan if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		} str.equals("0") str.equals str "0" {
    			break;
    		} break; {       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		} char[] charA; charA charA = str.toCharArray() charA str.toCharArray() str.toCharArray str int intt = 0; intt 0 for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			} int keta = 0; int keta = 0; keta 0 keta < charA.length keta charA.length charA charA.length keta++ keta++ keta {
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			} {
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			} char charAB = charA[keta]; charAB charA[keta] charA keta intt += Integer.parseInt(""+charAB) intt Integer.parseInt(""+charAB) Integer.parseInt Integer ""+charAB "" charAB System.out.println(intt) System.out.println System.out System System.out intt String[] args args
import java.util.Scanner;
//import java.io.*;

 class Main {
    public static void main(String[] args){ 
    	Scanner scan = new Scanner(System.in);
    	   	                                                 
    	String str;
    	
    	while(true){
    		str = scan.next();
    		if(str.equals("0")){
    			break;
    		}else{       
    			char[] charA;
    			charA = str.toCharArray();   //char????????????
    			int intt = 0;
    			for(int keta = 0; keta < charA.length; keta++){
    				char charAB = charA[keta];
    				intt += Integer.parseInt(""+charAB);   //int??????
    			}
    			System.out.println(intt);
    		}    			
    	}  	
     }
}