import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
} import java.io.*; io.* java public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
} Main public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }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 {
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        } while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            } true {
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            } String line = reader.readLine(); line reader.readLine() reader.readLine reader int sum = 0; sum 0 if(line.charAt(0)=='0'){
                    break;
                } line.charAt(0)=='0' line.charAt(0) line.charAt line 0 '0' {
                    break;
                } break; for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                } int i=0; int i=0; i 0 i<line.length() i line.length() line.length line i++ i++ i {
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                } {
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                } String num = String.valueOf(line.charAt(i)); num String.valueOf(line.charAt(i)) String.valueOf String line.charAt(i) line.charAt line i sum += Integer.parseInt(num) sum Integer.parseInt(num) Integer.parseInt Integer num System.out.printf("%d\n",sum) System.out.printf System.out System System.out "%d\n" sum String[] args args public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
} public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
} Main
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while(true){
                String line = reader.readLine();
                int sum = 0;
                if(line.charAt(0)=='0'){
                    break;
                }
                
                for(int i=0;i<line.length();i++){
                   String num = String.valueOf(line.charAt(i));
                   sum += Integer.parseInt(num);
                }
                System.out.printf("%d\n",sum);
            }
        }catch(IOException e){
            System.out.println(e);
        }
    }
}
