import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       int sum=0;
       while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       }
    }
} import java.util.*; util.* java import java.io.*; io.* java class Main{
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       int sum=0;
       while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       }
    }
} Main public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       int sum=0;
       while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       }
    } main {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       int sum=0;
       while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String s; s int sum=0; sum 0 while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       } (s = br.readLine())!=null (s = br.readLine()) s br.readLine() br.readLine br null {
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       } if("0".equals(s))break; "0".equals(s) "0".equals "0" s break; try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           } catch(NumberFormatException e){
           } NumberFormatException e {
           } {
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           } for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               } {
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               } int num = s.charAt(i) - 0x30; num s.charAt(i) - 0x30 s.charAt(i) s.charAt s i 0x30 sum += num sum num System.out.println(sum) System.out.println System.out System System.out sum sum=0 sum 0 String args[] args
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       int sum=0;
       while((s = br.readLine())!=null){
           if("0".equals(s))break;
           try{
               for(int i=0; i<s.length(); i++){
                   int num = s.charAt(i) - 0x30;
                   sum += num;
               }
               System.out.println(sum);
               sum=0;
           }catch(NumberFormatException e){
           }
       }
    }
}