import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    } main {
        Scanner scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String s; s while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        } !(s = scanner.next()).equals("0") (s = scanner.next()).equals("0") (s = scanner.next()).equals (s = scanner.next()) s scanner.next() scanner.next scanner "0" {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        } int sum = 0; sum 0 for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            } {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            } char c = s.charAt(i); c s.charAt(i) s.charAt s i int d = (c - '0'); d (c - '0') c '0' sum += d sum d 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 scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s;
        while (!(s = scanner.next()).equals("0")) {
            int sum = 0;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                int d = (c - '0');
                sum += d;
            }
            System.out.println(sum);
        }
    }
}
