import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        while(true){
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        }
        out.flush();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io class Main{
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        while(true){
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        }
        out.flush();
    }
} Main private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) private static final PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) public static void main(String[] Args) throws IOException{
        while(true){
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        }
        out.flush();
    } main {
        while(true){
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        }
        out.flush();
    } while(true){
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        } true {
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        } final String in = br.readLine(); in br.readLine() br.readLine br if(in.equals("0")) break; in.equals("0") in.equals in "0" break; int ans = 0; ans 0 for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            } int i = 0; int i = 0; i 0 i<in.length() i in.length() in.length in i++ i++ i {
                ans += in.charAt(i)-'0';
            } {
                ans += in.charAt(i)-'0';
            } ans += in.charAt(i)-'0' ans in.charAt(i)-'0' in.charAt(i) in.charAt in i '0' out.println(ans) out.println out ans out.flush() out.flush out String[] Args Args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        while(true){
            final String in = br.readLine();
            if(in.equals("0")) break;
            int ans = 0;
            for(int i = 0; i<in.length(); i++){
                ans += in.charAt(i)-'0';
            }
            out.println(ans);
        }
        out.flush();
    }
}