import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    }
} Main public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    } main {
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String a = in.next(); a in.next() in.next in int an = 0; an 0 while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        } !a.equals("0") a.equals("0") a.equals a "0" {
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        } int d = a.length(); d a.length() a.length a for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         } int i=0; int i=0; i 0 i<d i d i++ i++ i {
                 an+=a.charAt(i)-'0';
         } {
                 an+=a.charAt(i)-'0';
         } an+=a.charAt(i)-'0' an a.charAt(i)-'0' a.charAt(i) a.charAt a i '0' System.out.println(an) System.out.println System.out System System.out an an=0 an 0 a=in.next() a in.next() in.next in String[] args args public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        int an = 0;
         while(!a.equals("0")){
             int d = a.length();
             for(int i=0; i<d; i++){
                 an+=a.charAt(i)-'0';
         }
        System.out.println(an);
        an=0;
        a=in.next();                                                        
        }
    }
}