import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_B
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} import java.io.InputStreamReader; InputStreamReader java.io import java.io.LineNumberReader; LineNumberReader java.io public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} Main public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } main {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    } try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } catch (Exception e) {
            System.exit(-1);
        } Exception e {
            System.exit(-1);
        } System.exit(-1) System.exit System -1 1 {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in)); lineNumReader new LineNumberReader(
                    new InputStreamReader(System.in)) String inputStr = null; inputStr null long x = 0; x 0 int digit = 0; digit 0 int output = 0; output 0 while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            } (inputStr = lineNumReader.readLine()) != null (inputStr = lineNumReader.readLine()) inputStr lineNumReader.readLine() lineNumReader.readLine lineNumReader null {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            } output = 0 output 0 for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                } int i = 0; int i = 0; i 0 i < inputStr.length() i inputStr.length() inputStr.length inputStr i++ i++ i {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                } {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                } digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i))) digit Integer
                            .parseInt(String.valueOf(inputStr.charAt(i))) Integer
                            .parseInt Integer String.valueOf(inputStr.charAt(i)) String.valueOf String inputStr.charAt(i) inputStr.charAt inputStr i output += digit output digit if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                } inputStr.length() == 1 inputStr.length() inputStr.length inputStr 1 {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                } x = Integer.parseInt(inputStr) x Integer.parseInt(inputStr) Integer.parseInt Integer inputStr if (x == 0) {
                        // do nothing.
                        break;
                    } x == 0 x 0 {
                        // do nothing.
                        break;
                    } break; System.out.println(output) System.out.println System.out System System.out output lineNumReader.close() lineNumReader.close lineNumReader String[] args args public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
} Main
import java.io.InputStreamReader;
import java.io.LineNumberReader;

/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_B
 * 
 * @author eitatsuro
 * 
 */
public class Main {
    
    public static void main(String[] args) {
        try {
            LineNumberReader lineNumReader = new LineNumberReader(
                    new InputStreamReader(System.in));

            String inputStr = null;
            long x = 0;
            int digit = 0;
            int output = 0;
            
            while ((inputStr = lineNumReader.readLine()) != null) {

                output = 0;
                for (int i = 0; i < inputStr.length(); i++) {
                    digit = Integer
                            .parseInt(String.valueOf(inputStr.charAt(i)));
                    output += digit;
                }

                // ????????????
                // ?????°????°?????????????????????????????????§???????????????????????¨?????°????????§???
                if (inputStr.length() == 1) {
                    x = Integer.parseInt(inputStr);
                    if (x == 0) {
                        // do nothing.
                        break;
                    }
                }

                // ??¢???????????????
                System.out.println(output);


            }

            lineNumReader.close();
        } catch (Exception e) {
            System.exit(-1);
        }
        
    }
}