import java.util.Scanner;

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

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    }
} 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 x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        } true {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        } String x = sc.next(); x sc.next() sc.next sc if ("0".equals(x)) break; "0".equals(x) "0".equals "0" x break; int sum = 0; sum 0 for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            } String s x.split("") x.split x "" {
                sum += Integer.parseInt(s);
            } {
                sum += Integer.parseInt(s);
            } sum += Integer.parseInt(s) sum Integer.parseInt(s) Integer.parseInt Integer s 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) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    }
} Main
import java.util.Scanner;

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

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    }
}