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

public class Main {

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

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

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

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

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

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        } true {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        } String line = br.readLine(); line br.readLine() br.readLine br if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            } line.length() == 1 && line.charAt(0) == '0' line.length() == 1 line.length() line.length line 1 line.charAt(0) == '0' line.charAt(0) line.charAt line 0 '0' {
                break;
            } break; int sum = 0; sum 0 for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            } int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
                sum += line.charAt(i) - '0';
            } {
                sum += line.charAt(i) - '0';
            } sum += line.charAt(i) - '0' sum line.charAt(i) - '0' line.charAt(i) line.charAt line i '0' 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) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    }
} public class Main {

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

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

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

        while (true) {
            String line = br.readLine();
            if (line.length() == 1 && line.charAt(0) == '0') {
                break;
            }

            int sum = 0;
            for (int i = 0; i < line.length(); i++) {
                sum += line.charAt(i) - '0';
            }
            System.out.println(sum);
        }

    }
}
