import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);

    while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java import java.lang.*; lang.* java class Main{
  public static void main(String[] args) throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);

    while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    }
  }
} Main public static void main(String[] args) throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);

    while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    }
  } main {
    Scanner scan=new Scanner(System.in);

    while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    }
  } Scanner scan=new Scanner(System.in); scan new Scanner(System.in) while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    } true {
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    } String num=scan.next(); num scan.next() scan.next scan if(num.equals("0"))break; num.equals("0") num.equals num "0" break; long sum=0; sum 0 for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      } int i=0; int i=0; i 0 i<num.length() i num.length() num.length num i++ i++ i {
        sum+=Character.getNumericValue(num.charAt(i));
      } {
        sum+=Character.getNumericValue(num.charAt(i));
      } sum+=Character.getNumericValue(num.charAt(i)) sum Character.getNumericValue(num.charAt(i)) Character.getNumericValue Character num.charAt(i) num.charAt num i System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws java.lang.NumberFormatException{
    Scanner scan=new Scanner(System.in);

    while(true){
      String num=scan.next();
      if(num.equals("0"))break;

      long sum=0;

      for(int i=0;i<num.length();i++){
        sum+=Character.getNumericValue(num.charAt(i));
      }
      System.out.println(sum);
    }
  }
}
