import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        } true {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        } String nl = sc.nextLine(); nl sc.nextLine() sc.nextLine sc if ("0".equals(nl)) {
                break;
            } "0".equals(nl) "0".equals "0" nl {
                break;
            } break; int ans = 0; ans 0 for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            } int i = 0; int i = 0; i 0 i < nl.length() i nl.length() nl.length nl i++ i++ i {
                ans += Character.getNumericValue(nl.charAt(i));
            } {
                ans += Character.getNumericValue(nl.charAt(i));
            } ans += Character.getNumericValue(nl.charAt(i)) ans Character.getNumericValue(nl.charAt(i)) Character.getNumericValue Character nl.charAt(i) nl.charAt nl i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {

            String nl = sc.nextLine();

            if ("0".equals(nl)) {
                break;
            }

            int ans = 0;

            for (int i = 0; i < nl.length(); i++) {
                ans += Character.getNumericValue(nl.charAt(i));
            }

            System.out.println(ans);
        }
    }
}