import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    }
    
    private static void calc(String s) {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    }
}
 import java.util.*; util.* java public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    }
    
    private static void calc(String s) {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    } main {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    } while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        } true {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        } String s = sc.next(); s sc.next() sc.next sc if (s.equals("0")) break; s.equals("0") s.equals s "0" break; calc(s) calc s String[] args args private static void calc(String s) {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    } calc {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    } int ret = 0; ret 0 for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        } int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
            ret += Integer.parseInt(s.substring(i, i+1));
        } {
            ret += Integer.parseInt(s.substring(i, i+1));
        } ret += Integer.parseInt(s.substring(i, i+1)) ret Integer.parseInt(s.substring(i, i+1)) Integer.parseInt Integer s.substring(i, i+1) s.substring s i i+1 i 1 System.out.println(ret) System.out.println System.out System System.out ret String s s public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    }
    
    private static void calc(String s) {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    }
} public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    }
    
    private static void calc(String s) {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    }
} Main
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            calc(s);
        }
    }
    
    private static void calc(String s) {
        int ret = 0;
        for (int i = 0;i < s.length();i++) {
            ret += Integer.parseInt(s.substring(i, i+1));
        }
        System.out.println(ret);
    }
}

