import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) throws Exception {
        solve();
    }

} import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) throws Exception {
        solve();
    }

} Main static InputStream is; is static PrintWriter out; out static String INPUT = ""; INPUT "" final int INF = Integer.MAX_VALUE; INF Integer.MAX_VALUE Integer Integer.MAX_VALUE final int MIN = Integer.MIN_VALUE; MIN Integer.MIN_VALUE Integer Integer.MIN_VALUE static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    } solve {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        } true {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        } String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc int sum = 0; sum 0 for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            } int i = 0, l = line.length(); int i = 0 i 0 l = line.length(); l line.length() line.length line i < l i l i++ i++ i {
                sum += Integer.parseInt("" + line.charAt(i));
            } {
                sum += Integer.parseInt("" + line.charAt(i));
            } sum += Integer.parseInt("" + line.charAt(i)) sum Integer.parseInt("" + line.charAt(i)) Integer.parseInt Integer "" + line.charAt(i) "" line.charAt(i) line.charAt line i if (sum == 0) {
                break;
            } sum == 0 sum 0 {
                break;
            } break; System.out.println(sum) System.out.println System.out System System.out sum public static void main(String[] args) throws Exception {
        solve();
    } main {
        solve();
    } solve() solve String[] args args public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) throws Exception {
        solve();
    }

} public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) throws Exception {
        solve();
    }

} Main
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static InputStream is;
    static PrintWriter out;
    static String INPUT = "";

    final int INF = Integer.MAX_VALUE;
    final int MIN = Integer.MIN_VALUE;

    static void solve() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            int sum = 0;
            for (int i = 0, l = line.length(); i < l; i++) {
                sum += Integer.parseInt("" + line.charAt(i));
            }
            if (sum == 0) {
                break;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) throws Exception {
        solve();
    }

}