import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String number;
    	char[] ca;
    	int num;
    	
    	for(;;){
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	}
     }
} import java.util.Scanner; Scanner java.util class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String number;
    	char[] ca;
    	int num;
    	
    	for(;;){
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	}
     }
} Main public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String number;
    	char[] ca;
    	int num;
    	
    	for(;;){
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	}
     } main {
    	Scanner scan = new Scanner(System.in);
    	String number;
    	char[] ca;
    	int num;
    	
    	for(;;){
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	}
     } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String number; number char[] ca; ca int num; num for(;;){
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	} ; {
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	} {
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	} number = scan.next() number scan.next() scan.next scan ca =  number.toCharArray() ca number.toCharArray() number.toCharArray number num = 0 num 0 if(ca[0] == '0'){
    			break;
    		} ca[0] == '0' ca[0] ca 0 '0' {
    			break;
    		} break; for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	} int i = 0; int i = 0; i 0 i < ca.length i ca.length ca ca.length i++ i++ i {
	    		num += ca[i] - '0';
	    	} {
	    		num += ca[i] - '0';
	    	} num += ca[i] - '0' num ca[i] - '0' ca[i] ca i '0' System.out.println(num) System.out.println System.out System System.out num String[] args args
import java.util.Scanner;

class Main{
      public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	String number;
    	char[] ca;
    	int num;
    	
    	for(;;){
    		number = scan.next();
    		ca =  number.toCharArray();
    		num = 0;
    		
    		if(ca[0] == '0'){
    			break;
    		}
	    	for(int i = 0; i < ca.length; i++){
	    		num += ca[i] - '0';
	    	}
	    	System.out.println(num);
    	}
     }
}