import java.util.*;

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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s;
    int sum;
    while (!(s = sc.next()).equals("0")){
      sum = 0;
      for(int i = 0;i < s.length();i++){
        sum += Integer.parseInt(String.valueOf(s.charAt(i)));
      }
      System.out.println(sum);
    }
  }
}

