import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
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.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main
}//class import java.util.*; util.* java import java.text.*; text.* java 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.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main
}//class Main public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      int sum;
      
      while(true){
         sum = 0;
         str = sc.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main main {
      Scanner sc = new Scanner(System.in);
      String str;
      int sum;
      
      while(true){
         sum = 0;
         str = sc.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            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.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      } true {
         sum = 0;
         str = sc.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      } sum = 0 sum 0 str = sc.nextLine() str sc.nextLine() sc.nextLine sc if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         } str.equals("0") str.equals str "0" {
            break;
         } break; {
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         } 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){
      Scanner sc = new Scanner(System.in);
      String str;
      int sum;
      
      while(true){
         sum = 0;
         str = sc.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main
}//class 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.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main
}//class Main
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
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.nextLine();
         if(str.equals("0")){
            break;
         }else{
            for(int i = 0; i < str.length(); i ++){
               sum += Character.getNumericValue(str.charAt(i));
            }
            System.out.println(sum);
         }
         
         
      }
   }//main
}//class