import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String x = sc.next();
            int p = x.length();
            int a = 0;

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

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

            if(x.equals("0")){
                break;
            }else{
                for(int i=0;i<p;i++){
                    a += (x.charAt(i) - '0');
                }
                System.out.println(a);
            }
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String x = sc.next();
            int p = x.length();
            int a = 0;

            if(x.equals("0")){
                break;
            }else{
                for(int i=0;i<p;i++){
                    a += (x.charAt(i) - '0');
                }
                System.out.println(a);
            }
        }
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            String x = sc.next();
            int p = x.length();
            int a = 0;

            if(x.equals("0")){
                break;
            }else{
                for(int i=0;i<p;i++){
                    a += (x.charAt(i) - '0');
                }
                System.out.println(a);
            }
        } true {
            String x = sc.next();
            int p = x.length();
            int a = 0;

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

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

            if(x.equals("0")){
                break;
            }else{
                for(int i=0;i<p;i++){
                    a += (x.charAt(i) - '0');
                }
                System.out.println(a);
            }
        }
        sc.close();
    }
} Main
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String x = sc.next();
            int p = x.length();
            int a = 0;

            if(x.equals("0")){
                break;
            }else{
                for(int i=0;i<p;i++){
                    a += (x.charAt(i) - '0');
                }
                System.out.println(a);
            }
        }
        sc.close();
    }
}
