import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    }            
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    }            
} Main public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    } main {
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    } BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); buf new BufferedReader(new InputStreamReader(System.in)) int[] ans={}; ans {} while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        } true {
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        } String str=buf.readLine(); str buf.readLine() buf.readLine buf if(str.length()==1 && str.charAt(0)=='0'){break;} str.length()==1 && str.charAt(0)=='0' str.length()==1 str.length() str.length str 1 str.charAt(0)=='0' str.charAt(0) str.charAt str 0 '0' {break;} break; int sum=0; sum 0 for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
                sum +=str.charAt(i)-'0';
            } {
                sum +=str.charAt(i)-'0';
            } sum +=str.charAt(i)-'0' sum str.charAt(i)-'0' str.charAt(i) str.charAt str i '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    }            
} public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    }            
} Main
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        int[] ans={};
        
        while(true){
            String str=buf.readLine();
            if(str.length()==1 && str.charAt(0)=='0'){break;}
            
            int sum=0;
            for(int i=0;i<str.length();i++){
                sum +=str.charAt(i)-'0';
            }
            System.out.println(sum);
        }
    }            
}