public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  } run {
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  } java.util.Scanner sc = new java.util.Scanner(in); sc new java.util.Scanner(in) String str; str char[] ch; ch int i i n n m; m for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    } ; {
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    } {
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    } str = sc.nextLine() str sc.nextLine() sc.nextLine sc m = str.length() m str.length() str.length str ch = new char[m] ch new char[m] m n = 0 n 0 for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      } i = 0; i = 0 i 0 i < m i m i++ i++ i {
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      } {
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      } ch[i] = str.charAt(i) ch[i] ch i str.charAt(i) str.charAt str i n += (int)(ch[i] - '0') n (int)(ch[i] - '0') ch[i] ch i '0' if(n == 0)break; n == 0 n 0 break; System.out.println(n) System.out.println System.out System System.out n sc.close() sc.close sc java.io.InputStream in in java.io.PrintStream out out public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  } main {
    (new Main()).run(System.in, System.out);
  } (new Main()).run(System.in, System.out) (new Main()).run (new Main()) System.in System System.in System.out System System.out String[] args args public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
} Main
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String str;
    char[] ch;
    int i, n, m;

    for(;;){
      str = sc.nextLine();
      m = str.length();
      ch = new char[m];
      n = 0;
      for(i = 0;i < m;i++){
        ch[i] = str.charAt(i);
        n += (int)(ch[i] - '0');
      }

      if(n == 0)break;
      System.out.println(n);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}