import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    }
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    }
} Main public static void main(String[] args) {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    } main {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        } true {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        } String str = scan.nextLine(); str scan.nextLine() scan.nextLine scan if (str.equals("0")) break; str.equals("0") str.equals str "0" break; int sum = 0; sum 0 char[] box = str.toCharArray(); box str.toCharArray() str.toCharArray str for (int i = 0; i < box.length; i++)
                sum += box[i] - '0'; int i = 0; int i = 0; i 0 i < box.length i box.length box box.length i++ i++ i sum += box[i] - '0'; sum += box[i] - '0' sum box[i] - '0' box[i] box i '0' 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 scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    }
} public class Main {
	public static void main(String[] args) {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    }
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 
        Scanner scan = new Scanner(System.in);
 
        while (true) {
            String str = scan.nextLine();
            if (str.equals("0")) break;
            int sum = 0;
            char[] box = str.toCharArray();
            for (int i = 0; i < box.length; i++)
                sum += box[i] - '0';
            System.out.println(sum);
        }
 
    }
}