import java.util.Scanner;
class Main{
 public static void main(String[] args){
  String s;
  int i,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  }
 }
} import java.util.Scanner; Scanner java.util class Main{
 public static void main(String[] args){
  String s;
  int i,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  }
 }
} Main public static void main(String[] args){
  String s;
  int i,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  }
 } main {
  String s;
  int i,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  }
 } String s; s int i i g; g Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  } true {
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  } s=sc.next() s sc.next() sc.next sc if(s.equals("0"))break; s.equals("0") s.equals s "0" break; g=0 g 0 for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48; i=0; i=0 i 0 i<s.length() i s.length() s.length s i++ i++ i g+=s.charAt(i)-48; g+=s.charAt(i)-48 g s.charAt(i)-48 s.charAt(i) s.charAt s i 48 System.out.println(g) System.out.println System.out System System.out g String[] args args
import java.util.Scanner;
class Main{
 public static void main(String[] args){
  String s;
  int i,g;
  Scanner sc = new Scanner(System.in);
  while(true){
   s=sc.next();
   if(s.equals("0"))break;
   g=0;
   for(i=0;i<s.length();i++)
    g+=s.charAt(i)-48;
   System.out.println(g);
  }
 }
}
