import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    } main {
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int l l i i j j n n S=0; S 0 String c=""; c "" for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } i=0; i=0 i 0 i++ i++ i {
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } {
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } c=sc.next() c sc.next() sc.next sc l=c.length() l c.length() c.length c if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            } c.equals("0") c.equals c "0" {
                break;
            } break; {
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            } for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                } j=0; j=0 j 0 j<=l-1 j l-1 l 1 j++ j++ j {
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                } {
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                } n=Integer.parseInt(c.substring(j,j+1)) n Integer.parseInt(c.substring(j,j+1)) Integer.parseInt Integer c.substring(j,j+1) c.substring c j j+1 j 1 S+=n S n System.out.println(S) System.out.println System.out System System.out S S=0 S 0 String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    }
} Main
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int l,i,j,n,S=0;
        String c="";
        for(i=0; ;i++){
            c=sc.next();    
            l=c.length();
            if(c.equals("0")){
                break;
            }else{
                for(j=0;j<=l-1;j++){
                    n=Integer.parseInt(c.substring(j,j+1));
                    S+=n;
                }
            }
            System.out.println(S); 
            S=0;                   
        } 
    }
}
