import java.util.Scanner;

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

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        } sc.hasNext() sc.hasNext sc {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        } String box = sc.next(); box sc.next() sc.next sc if (box.equals("0"))
                break; box.equals("0") box.equals box "0" break; int sum = 0; sum 0 for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            } int i=0; int i=0; i 0 i<box.length() i box.length() box.length box i++ i++ i {
                sum+=box.charAt(i)-'0';
            } {
                sum+=box.charAt(i)-'0';
            } sum+=box.charAt(i)-'0' sum box.charAt(i)-'0' box.charAt(i) box.charAt box i '0' System.out.printf("%d\n",sum) System.out.printf System.out System System.out "%d\n" sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    }
} Main
import java.util.Scanner;

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

        while(sc.hasNext()) {
            String box = sc.next();

            if (box.equals("0"))
                break;

            int sum = 0;
            for(int i=0; i<box.length(); i++){
                sum+=box.charAt(i)-'0';
            }
            System.out.printf("%d\n",sum);
        }
    }
}

