import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    }
}              

     import java.math.BigDecimal; BigDecimal java.math import java.math.BigInteger; BigInteger java.math import java.util.Scanner; Scanner java.util import javax.sound.midi.SysexMessage; SysexMessage javax.sound.midi public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    } main {
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i = 0; i 0 for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        } ; i<1000 i 1000 i++ i++ i {
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        } {
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        } int ans=0; ans 0 BigInteger m = sc.nextBigInteger(); m sc.nextBigInteger() sc.nextBigInteger sc if(m.compareTo(BigInteger.ZERO)==0)
                break; m.compareTo(BigInteger.ZERO)==0 m.compareTo(BigInteger.ZERO) m.compareTo m BigInteger.ZERO BigInteger BigInteger.ZERO 0 break; int len = String.valueOf(m).length(); len String.valueOf(m).length() String.valueOf(m).length String.valueOf(m) String.valueOf String m for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            } int j = 0; int j = 0; j 0 j<len j len j++ j++ j {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            } {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            } ans += Character.getNumericValue(String.valueOf(m).charAt(j)) ans Character.getNumericValue(String.valueOf(m).charAt(j)) Character.getNumericValue Character String.valueOf(m).charAt(j) String.valueOf(m).charAt String.valueOf(m) String.valueOf String m j System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    }
} public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    }
} Main
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 0;
        for(;i<1000;i++){
            int ans=0;
            BigInteger m = sc.nextBigInteger();
            if(m.compareTo(BigInteger.ZERO)==0)
                break;
            int len = String.valueOf(m).length();
            for (int j = 0; j<len; j++)
            {
                ans += Character.getNumericValue(String.valueOf(m).charAt(j));
            }
            System.out.println(ans);  
        }
       
    }
}              

    
