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