import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  }
} import java.util.Scanner; Scanner java.util public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  }
} Main public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  } main {
    Scanner in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    } true {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    } char[] number = in.next().toCharArray(); number in.next().toCharArray() in.next().toCharArray in.next() in.next in if (number[0] == '0') break; number[0] == '0' number[0] number 0 '0' break; int sum = 0; sum 0 for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      } int i = 0; int i = 0; i 0 i < number.length i number.length number number.length i++ i++ i {
        sum += Character.getNumericValue(number[i]);
      } {
        sum += Character.getNumericValue(number[i]);
      } sum += Character.getNumericValue(number[i]) sum Character.getNumericValue(number[i]) Character.getNumericValue Character number[i] number 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 in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  }
} public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  }
} Main
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    while(true) {
      char[] number = in.next().toCharArray();
      if (number[0] == '0') break;
      int sum = 0;
      for (int i = 0; i < number.length; i++) {
        sum += Character.getNumericValue(number[i]);
      }
      System.out.println(sum);
    }
  }
}