import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        } true {
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        } int sum = 0; sum 0 String s = sc.next(); s sc.next() sc.next sc if(s.equals("0")) break; s.equals("0") s.equals s "0" break; for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
                char a = s.charAt(i);
                sum += a - '0';
            } {
                char a = s.charAt(i);
                sum += a - '0';
            } char a = s.charAt(i); a s.charAt(i) s.charAt s i sum += a - '0' sum a - '0' a '0' System.out.printf("%d\n", sum) System.out.printf System.out System System.out "%d\n" sum String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int sum = 0;            
            String s = sc.next();
            if(s.equals("0")) break;
            for(int i=0;i<s.length();i++){
                char a = s.charAt(i);
                sum += a - '0';
            }
            System.out.printf("%d\n", sum);
        }
    }
}
