import java.util.Scanner;

public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    }   
     
} import java.util.Scanner; Scanner java.util public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    }   
     
} Main public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    } main {
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) String in; in String number; number char[] num=new char[1000]; num new char[1000] 1000 int result=0; result 0 int add=0; add 0 while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        } true {
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        } in=scan.nextLine() in scan.nextLine() scan.nextLine scan if(in.equals("0")){
                break;
            } in.equals("0") in.equals in "0" {
                break;
            } break; number=in number in num=number.toCharArray() num number.toCharArray() number.toCharArray number result=0 result 0 for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            } int i=0; int i=0; i 0 i<num.length i num.length num num.length i++ i++ i {
                add=Character.digit(num[i], 10);
                result+=add;
            } {
                add=Character.digit(num[i], 10);
                result+=add;
            } add=Character.digit(num[i], 10) add Character.digit(num[i], 10) Character.digit Character num[i] num i 10 result+=add result add System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    }   
     
} public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    }   
     
} Main
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    }   
     
}