import java.io.*;
import java.util.*;

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

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        
        while (true) {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String[] args)throws IOException{

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        
        while (true) {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        }
    }
} Main public static void main(String[] args)throws IOException{

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        
        while (true) {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        }
    } main {

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        
        while (true) {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        }
    } InputStreamReader isr =new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br =new BufferedReader(isr); br new BufferedReader(isr) String buf = br.readLine(); buf br.readLine() br.readLine br while (true) {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        } true {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        } int i i sum = 0; sum 0 if (Character.getNumericValue(buf.charAt(0)) == 0) break; Character.getNumericValue(buf.charAt(0)) == 0 Character.getNumericValue(buf.charAt(0)) Character.getNumericValue Character buf.charAt(0) buf.charAt buf 0 0 break; for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            } i = 0; i = 0 i 0 i < buf.length() i buf.length() buf.length buf i++ i++ i {
                sum += Character.getNumericValue(buf.charAt(i));
            } {
                sum += Character.getNumericValue(buf.charAt(i));
            } sum += Character.getNumericValue(buf.charAt(i)) sum Character.getNumericValue(buf.charAt(i)) Character.getNumericValue Character buf.charAt(i) buf.charAt buf i System.out.println(sum) System.out.println System.out System System.out sum buf = br.readLine() buf br.readLine() br.readLine br String[] args args
import java.io.*;
import java.util.*;

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

        InputStreamReader isr =new InputStreamReader(System.in);
   		BufferedReader br =new BufferedReader(isr);
    	String buf = br.readLine();
        
        while (true) {
            int i, sum = 0;
            if (Character.getNumericValue(buf.charAt(0)) == 0) break;
            for (i = 0;i < buf.length();i++) {
                sum += Character.getNumericValue(buf.charAt(i));
            }
            System.out.println(sum);
            buf = br.readLine();
        }
    }
}