import java.util.*;

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

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

