import java.util.Scanner;

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

    private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    } try (Scanner in = new Scanner(System.in)) {
            solve(in);
        } {
            solve(in);
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) solve(in) solve in String[] args args private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    } solve {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    } for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        } String x = in.next(); String x = in.next(); x in.next() in.next in !x.equals("0") x.equals("0") x.equals x "0" x = in.next() x = in.next() x in.next() in.next in {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        } {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        } int sum = 0; sum 0 for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            } int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
                sum += (x.charAt(i) - '0');
            } {
                sum += (x.charAt(i) - '0');
            } sum += (x.charAt(i) - '0') sum (x.charAt(i) - '0') x.charAt(i) x.charAt x i '0' System.out.println(sum) System.out.println System.out System System.out sum Scanner in in public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} Main
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        for (String x = in.next(); !x.equals("0"); x = in.next()) {
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += (x.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
}