import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int sum = 0; sum 0 while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        } true {

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        } String x = br.readLine(); x br.readLine() br.readLine br char[] charKeta = x.toCharArray(); charKeta x.toCharArray() x.toCharArray x if(x.equals("0")){
                break;
            } x.equals("0") x.equals x "0" {
                break;
            } break; for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            } int i = 0; int i = 0; i 0 i < charKeta.length i charKeta.length charKeta charKeta.length i++ i++ i {
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            } {
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            } int intKeta = Character.getNumericValue(charKeta[i]); intKeta Character.getNumericValue(charKeta[i]) Character.getNumericValue Character charKeta[i] charKeta i sum += intKeta sum intKeta System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 String[] args args public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int sum = 0;

        while(true){

            //???????????¨??????????????????
            String x = br.readLine();
            //????????????????????????????´?
            char[] charKeta = x.toCharArray();

            //???????????¶
            if(x.equals("0")){
                break;
            }

            for(int i = 0; i < charKeta.length; i++){
                //char?????????int???????????£??????
                int intKeta = Character.getNumericValue(charKeta[i]);
                sum += intKeta;
            }
            System.out.println(sum);
            sum = 0;
        }
    }
}