import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        int sum;
        
        while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        }
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        int sum;
        
        while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        int sum;
        
        while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        }
    } main {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        int sum;
        
        while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        }
    } int i i j; j Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String str; str Character c; c int sum; sum while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        } true {
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        } str=sc.next() str sc.next() sc.next sc if(str.equals("0"))break; str.equals("0") str.equals str "0" break; sum=0 sum 0 for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            } i=0; i=0 i 0 i<str.length() i str.length() str.length str i++ i++ i {
                c=str.charAt(i);
                sum+=c-'0';
            } {
                c=str.charAt(i);
                sum+=c-'0';
            } c=str.charAt(i) c str.charAt(i) str.charAt str i sum+=c-'0' sum c-'0' c '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) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        int sum;
        
        while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        int i,j;
        
        Scanner sc=new Scanner(System.in);
        
        String str;
        Character c;
        int sum;
        
        while(true){
            str=sc.next();
            if(str.equals("0"))break;
            
            sum=0;
            for(i=0;i<str.length();i++){
                c=str.charAt(i);
                sum+=c-'0';
            }
            
            System.out.println(sum);
        }
    }
} Main
import java.util.*;

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

