import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        }catch(IOException e){
            System.out.println(e);
        }
    }
} import java.io.*; io.* java class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        }catch(IOException e){
            System.out.println(e);
        }
    }
} Main public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        }catch(IOException e){
            System.out.println(e);
        }
    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        }catch(IOException e){
            System.out.println(e);
        }
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try{
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        }catch(IOException e){
            System.out.println(e);
        } catch(IOException e){
            System.out.println(e);
        } IOException e {
            System.out.println(e);
        } System.out.println(e) System.out.println System.out System System.out e {
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        } String line = reader.readLine(); line reader.readLine() reader.readLine reader char tmp = line.charAt(0); tmp line.charAt(0) line.charAt line 0 int sum=0 sum 0 i; i while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            } true {
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            } int x = tmp - '0'; x tmp - '0' tmp '0' sum += x sum x if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                } sum==0 sum 0 break; {
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                } for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    } i=1; i=1 i 1 i<line.length() i line.length() line.length line i++ i++ i {
                        sum += line.charAt(i) - '0';
                    } {
                        sum += line.charAt(i) - '0';
                    } sum += line.charAt(i) - '0' sum line.charAt(i) - '0' line.charAt(i) line.charAt line i '0' System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 line = reader.readLine() line reader.readLine() reader.readLine reader tmp = line.charAt(0) tmp line.charAt(0) line.charAt line 0 String[] args args
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            char tmp = line.charAt(0);
            int sum=0,i;

            while(true){
                int x = tmp - '0';
                sum += x;
                if(sum==0) break;
                else{
                    for(i=1;i<line.length();i++){
                        sum += line.charAt(i) - '0';
                    }
                    System.out.println(sum);
                }
                sum = 0;
                line = reader.readLine();
                tmp = line.charAt(0);
            }

        }catch(IOException e){
            System.out.println(e);
        }
    }
}
