import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    } main {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String string = scan.nextLine(); string scan.nextLine() scan.nextLine scan char[] a = string.toCharArray(); a string.toCharArray() string.toCharArray string while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        } a[0] != '0' a[0] a 0 '0' {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        } int i = 0; i 0 int sum = 0; sum 0 while (i < a.length) {
                sum += a[i++] - '0';
            } i < a.length i a.length a a.length {
                sum += a[i++] - '0';
            } sum += a[i++] - '0' sum a[i++] - '0' a[i++] a i++ i '0' System.out.println(sum) System.out.println System.out System System.out sum string = scan.nextLine() string scan.nextLine() scan.nextLine scan a = string.toCharArray() a string.toCharArray() string.toCharArray string String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String string = scan.nextLine();
        char[] a = string.toCharArray();

        while (a[0] != '0') {
            int i = 0;
            int sum = 0;
            while (i < a.length) {
                sum += a[i++] - '0';
            }
            System.out.println(sum);
            string = scan.nextLine();
            a = string.toCharArray();
        }
    }
}