import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    }

        
} import java.io.*; io.* java public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    }

        
} Main public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } true {
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } String str =br.readLine(); str br.readLine() br.readLine br if(str.equals("0")){
               break;
           } str.equals("0") str.equals str "0" {
               break;
           } break; int sum=0; sum 0 for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
               sum+=Character.getNumericValue(str.charAt(i));
           } {
               sum+=Character.getNumericValue(str.charAt(i));
           } sum+=Character.getNumericValue(str.charAt(i)) sum Character.getNumericValue(str.charAt(i)) Character.getNumericValue Character str.charAt(i) str.charAt str i 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) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    }

        
} public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    }

        
} Main
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       while(true){
           String str =br.readLine();
           if(str.equals("0")){
               break;
           }
           int sum=0;
           for(int i=0;i<str.length();i++){
               sum+=Character.getNumericValue(str.charAt(i));
           }
           System.out.println(sum);
       } 
        
        
    }

        
}