import java.io.*;

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

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