import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){
    String input;
 
    Scanner in = new Scanner(System.in);

    while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    }

  }
} import java.util.Scanner; Scanner java.util class Main{
  public static void main(String[] arg){
    String input;
 
    Scanner in = new Scanner(System.in);

    while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    }

  }
} Main public static void main(String[] arg){
    String input;
 
    Scanner in = new Scanner(System.in);

    while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    }

  } main {
    String input;
 
    Scanner in = new Scanner(System.in);

    while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    }

  } String input; input Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    } true {
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    } input = in.nextLine() input in.nextLine() in.nextLine in if(input.equals("0")) break; input.equals("0") input.equals input "0" break; int tmp=0; tmp 0 for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        } int i=0; int i=0; i 0 i<input.length() i input.length() input.length input ++i ++i i {
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        } {
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        } char ch = input.charAt(i); ch input.charAt(i) input.charAt input i tmp += Character.getNumericValue(ch) tmp Character.getNumericValue(ch) Character.getNumericValue Character ch System.out.println(tmp) System.out.println System.out System System.out tmp String[] arg arg
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){
    String input;
 
    Scanner in = new Scanner(System.in);

    while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    }

  }
}