import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String x = stdin.next();
      if (x.equals("0")) {
        break;
      }

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

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String x = stdin.next();
      if (x.equals("0")) {
        break;
      }

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

} Main public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String x = stdin.next();
      if (x.equals("0")) {
        break;
      }

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

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

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

      int sum = 0;
      int len = x.length();
      for (int i = 0; i < len; i++) {
        sum += Character.getNumericValue(x.charAt(i));
      }
      System.out.println(sum);
    } String x = stdin.next(); x stdin.next() stdin.next stdin if (x.equals("0")) {
        break;
      } x.equals("0") x.equals x "0" {
        break;
      } break; int sum = 0; sum 0 int len = x.length(); len x.length() x.length x for (int i = 0; i < len; i++) {
        sum += Character.getNumericValue(x.charAt(i));
      } int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
        sum += Character.getNumericValue(x.charAt(i));
      } {
        sum += Character.getNumericValue(x.charAt(i));
      } sum += Character.getNumericValue(x.charAt(i)) sum Character.getNumericValue(x.charAt(i)) Character.getNumericValue Character x.charAt(i) x.charAt x 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 stdin = new Scanner(System.in);
    while (true) {
      String x = stdin.next();
      if (x.equals("0")) {
        break;
      }

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

} public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String x = stdin.next();
      if (x.equals("0")) {
        break;
      }

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

} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      String x = stdin.next();
      if (x.equals("0")) {
        break;
      }

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

}