import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    }


} import java.io.BufferedReader; BufferedReader java.io import java.io.BufferedWriter; BufferedWriter java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.OutputStreamWriter; OutputStreamWriter java.io import java.io.IOException; IOException java.io public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    }


} Main public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw new BufferedWriter(new OutputStreamWriter(System.out)) String input; input while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        } !(input = br.readLine()).equals("0") (input = br.readLine()).equals("0") (input = br.readLine()).equals (input = br.readLine()) input br.readLine() br.readLine br "0" {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        } int count = 0; count 0 for (char c : input.toCharArray()) {
                count += (c - '0');
            } char c input.toCharArray() input.toCharArray input {
                count += (c - '0');
            } {
                count += (c - '0');
            } count += (c - '0') count (c - '0') c '0' bw.append(count + "\n") bw.append bw count + "\n" count "\n" bw.flush() bw.flush bw String args[] args public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    }


} public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    }


} Main
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String input;
        while (!(input = br.readLine()).equals("0")) {
            int count = 0;
            for (char c : input.toCharArray()) {
                count += (c - '0');
            }
            bw.append(count + "\n");
        }
        bw.flush();
    }


}
