import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  }
} Main public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  } main {
    Scanner scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    } true {
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    } String a = scanner.next(); a scanner.next() scanner.next scanner if(a.equals("0")) break; a.equals("0") a.equals a "0" break; int sum = 0; sum 0 for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    } int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    } {
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    } char num = a.charAt(i); num a.charAt(i) a.charAt a i sum += Integer.parseInt("" + num) sum Integer.parseInt("" + num) Integer.parseInt Integer "" + num "" num 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 scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  }
} public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
    String a = scanner.next();
    if(a.equals("0")) break;
    int sum = 0;
    for(int i = 0; i < a.length(); i++){
      char num = a.charAt(i);
      sum += Integer.parseInt("" + num);
    }
    System.out.println(sum);
    }
  }
}