import java.io.*;
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    }
}
 import java.io.*; io.* java public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    }
} Main public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        } true {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        } int i i sum=0; sum 0 try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } 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();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } String line = reader.readLine(); line reader.readLine() reader.readLine reader if(line.equals("0")) break; line.equals("0") line.equals line "0" break; for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                } i=0; i=0 i 0 i<line.length() i line.length() line.length line i++ i++ i {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                } {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                } char c = line.charAt(i); c line.charAt(i) line.charAt line i sum += Character.getNumericValue(c) sum Character.getNumericValue(c) Character.getNumericValue Character c 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) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    }
} public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    }
} Main
import java.io.*;
public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            int i,sum=0;
            try {
                String line = reader.readLine();
                if(line.equals("0")) break;
                for(i=0;i<line.length();i++) {
                    char c = line.charAt(i);
                    sum += Character.getNumericValue(c);
                }
            } catch (IOException e) {
                System.out.println(e);
            }
            System.out.println(sum);
        }


    }
}

