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

public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    }
}
 import java.io.ByteArrayInputStream; ByteArrayInputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    }
} Main String INPUT = ""; INPUT "" public static void main(String[] args) throws Exception {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    } run {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    } Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes())); sc INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes())) INPUT.isEmpty() INPUT.isEmpty INPUT new Scanner(System.in) new Scanner(new ByteArrayInputStream(INPUT.getBytes())) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) solve(sc, out) solve sc out out.flush() out.flush out void solve(Scanner sc, PrintWriter out) {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    } solve {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    } String S = sc.nextLine(); S sc.nextLine() sc.nextLine sc while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        } !"0".equals(S) "0".equals(S) "0".equals "0" S {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        } int sum = 0; sum 0 for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
                sum += (int)S.charAt(i)-'0';
            } {
                sum += (int)S.charAt(i)-'0';
            } sum += (int)S.charAt(i)-'0' sum (int)S.charAt(i)-'0' (int)S.charAt(i) S.charAt S i '0' System.out.println(sum) System.out.println System.out System System.out sum S = sc.nextLine() S sc.nextLine() sc.nextLine sc Scanner sc sc PrintWriter out out public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    }
} public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    }
} Main
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        String S = sc.nextLine();
        while (!"0".equals(S)) {
            int sum = 0;
            for (int i = 0; i < S.length(); i++) {
                sum += (int)S.charAt(i)-'0';
            }
            System.out.println(sum);
            S = sc.nextLine();
        }
    }
}

