import java.util.*;
public class Main{
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

}
}
 import java.util.*; util.* java public class Main{
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

}
} Main public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

} main {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
} true {
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
} String b = sc.next(); b sc.next() sc.next sc int a = b.length(); a b.length() b.length b int goukei = 0; goukei 0 int kazu[] = new int [a]; kazu new int [a] a if(b.equals("0"))
    break; b.equals("0") b.equals b "0" break; for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  } int i = 0; int i = 0; i 0 i<a i a i++ i++ i {
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  } {
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  } kazu[i] = b.charAt(i)-'0' kazu[i] kazu i b.charAt(i)-'0' b.charAt(i) b.charAt b i '0' goukei += kazu[i] goukei kazu[i] kazu i System.out.println(goukei) System.out.println System.out System System.out goukei String[] args args public class Main{
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

}
} public class Main{
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

}
} Main
import java.util.*;
public class Main{
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

while(true){
  String b = sc.next();
  int a = b.length();
  int goukei = 0;
  int kazu[] = new int [a];

  if(b.equals("0"))
    break;
  for(int i = 0; i<a; i++){
    kazu[i] = b.charAt(i)-'0';
    goukei += kazu[i];
  }
  System.out.println(goukei);
}

}
}

