import java.util.Scanner;

class Main {
  static Scanner in = new Scanner(System.in);
  public static void main(String[] args) {
    
    while(in.hasNext()){
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    }
  }
} import java.util.Scanner; Scanner java.util class Main {
  static Scanner in = new Scanner(System.in);
  public static void main(String[] args) {
    
    while(in.hasNext()){
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    }
  }
} Main static Scanner in = new Scanner(System.in); in new Scanner(System.in) public static void main(String[] args) {
    
    while(in.hasNext()){
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    }
  } main {
    
    while(in.hasNext()){
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    }
  } while(in.hasNext()){
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    } in.hasNext() in.hasNext in {
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    } int sum = 0; sum 0 String input = in.next(); input in.next() in.next in if (input.equals("0")) break; input.equals("0") input.equals input "0" break; for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0'; int i = 0; int i = 0; i 0 i < input.length() i input.length() input.length input i++ i++ i sum += input.charAt(i) - '0'; sum += input.charAt(i) - '0' sum input.charAt(i) - '0' input.charAt(i) input.charAt input i '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;

class Main {
  static Scanner in = new Scanner(System.in);
  public static void main(String[] args) {
    
    while(in.hasNext()){
      int sum = 0;
      String input = in.next();
      if (input.equals("0")) break;
      for (int i = 0; i < input.length(); i++) sum += input.charAt(i) - '0';
      System.out.println(sum);
    }
  }
}