import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i; i String str = "1"; str "1" int sum = 0; sum 0 int value = 1; value 1 while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        } true {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        } str = sc.next() str sc.next() sc.next sc if(str.equals("0")){
                break;
            } str.equals("0") str.equals str "0" {
                break;
            } break; for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            } i = 0; i = 0 i 0 i < str.length() i str.length() str.length str i++ i++ i {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            } {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            } str.charAt(i) str.charAt str i value = str.charAt(i) -'0' value str.charAt(i) -'0' str.charAt(i) str.charAt str i '0' sum += value sum value System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 sc.close() sc.close sc String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int i;
        String str = "1";
        int sum = 0;
        int value = 1;
        while (true) {
            str = sc.next();
            if(str.equals("0")){
                break;
            }
            for (i = 0; i < str.length(); i++) {
                str.charAt(i);
                value = str.charAt(i) -'0';
                sum += value;
            }
            System.out.println(sum);
            sum = 0;    
        }
        sc.close();
    }
}
