import java.util.Scanner;

/**
 * Sum of Numbers
 */
public class Main {
    private static Scanner scan;

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

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    private static Scanner scan;

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

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} Main private static Scanner scan; scan public static void main(String[] args) {
        scan = new Scanner(System.in);

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    } main {
        scan = new Scanner(System.in);

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    } scan = new Scanner(System.in) scan new Scanner(System.in) String r; r int sum = 0; sum 0 while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        } scan.hasNext() scan.hasNext scan {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        } r = scan.next() r scan.next() scan.next scan if (r.equals("0")) {
                break;
            } r.equals("0") r.equals r "0" {
                break;
            } break; for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            } int i = 0; int i = 0; i 0 i < r.toString().length() i r.toString().length() r.toString().length r.toString() r.toString r i++ i++ i {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            } {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            } sum += Integer.parseInt(r.toString().substring(i, i + 1)) sum Integer.parseInt(r.toString().substring(i, i + 1)) Integer.parseInt Integer r.toString().substring(i, i + 1) r.toString().substring r.toString() r.toString r i i + 1 i 1 System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 String[] args args public class Main {
    private static Scanner scan;

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

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} public class Main {
    private static Scanner scan;

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

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
} Main
import java.util.Scanner;

/**
 * Sum of Numbers
 */
public class Main {
    private static Scanner scan;

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

        String r;
        int sum = 0;
        while (scan.hasNext()) {
            r = scan.next();
            if (r.equals("0")) {
                break;
            }
            for (int i = 0; i < r.toString().length(); i++) {
                sum += Integer.parseInt(r.toString().substring(i, i + 1));
            }
            System.out.println(sum);
            sum = 0;
        }
    }
}