import java.io.*;

class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str;
        int sum = 0;

        while(true){
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} import java.io.*; io.* java class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str;
        int sum = 0;

        while(true){
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} Main public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str;
        int sum = 0;

        while(true){
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str;
        int sum = 0;

        while(true){
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str int sum = 0; sum 0 while(true){
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        } true {
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        } str = br.readLine() str br.readLine() br.readLine br if(str.equals("0"))break; str.equals("0") str.equals str "0" break; for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
                sum += Integer.parseInt(str.substring(i,i+1));
            } {
                sum += Integer.parseInt(str.substring(i,i+1));
            } sum += Integer.parseInt(str.substring(i,i+1)) sum Integer.parseInt(str.substring(i,i+1)) Integer.parseInt Integer str.substring(i,i+1) str.substring str i i+1 i 1 System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 String[]args args
import java.io.*;

class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String str;
        int sum = 0;

        while(true){
            str = br.readLine();

            if(str.equals("0"))break;
            
            for(int i=0; i<str.length(); i++){
                sum += Integer.parseInt(str.substring(i,i+1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
}