import java.util.*;

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

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

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

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

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

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

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

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

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

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

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

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String s = sc.next();

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        } true {
            String s = sc.next();

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        } String s = sc.next(); s sc.next() sc.next sc if (s.length() == 1 && s.charAt(0) == '0')
                break; s.length() == 1 && s.charAt(0) == '0' s.length() == 1 s.length() s.length s 1 s.charAt(0) == '0' s.charAt(0) s.charAt s 0 '0' break; int sum = 0; sum 0 for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10); int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i sum += Character.digit(s.charAt(i), 10); sum += Character.digit(s.charAt(i), 10) sum Character.digit(s.charAt(i), 10) Character.digit Character s.charAt(i) s.charAt s i 10 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 s = sc.next();

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

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

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

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

    }
} Main
import java.util.*;

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

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

            if (s.length() == 1 && s.charAt(0) == '0')
                break;

            int sum = 0;

            for (int i = 0; i < s.length(); i++)
                sum += Character.digit(s.charAt(i), 10);

            System.out.println(sum);
        }

    }
}

