import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                }
        }
} import java.util.*; util.* java class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                }
        }
} Main public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                }
        } main {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                }
        } try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                } {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        } true {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        } String S = sc.next(); S sc.next() sc.next sc if (S.equals("0")) {
                                        break;
                                } S.equals("0") S.equals S "0" {
                                        break;
                                } break; long ans = 0; ans 0 for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                } int i = 0; int i = 0; i 0 i < S.length() i S.length() S.length S i++ i++ i {
                                        ans += S.charAt(i) - '0';
                                } {
                                        ans += S.charAt(i) - '0';
                                } ans += S.charAt(i) - '0' ans S.charAt(i) - '0' S.charAt(i) S.charAt S i '0' System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        while (true) {
                                String S = sc.next();
                                if (S.equals("0")) {
                                        break;
                                }
                                long ans = 0;
                                for (int i = 0; i < S.length(); i++) {
                                        ans += S.charAt(i) - '0';
                                }
                                System.out.println(ans);
                        }
                }
        }
}