import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
} import java.util.Scanner; Scanner java.util class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public void run() {
        while (true) {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        }
    } run {
        while (true) {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        }
    } while (true) {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        } true {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        } String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc if("0".equals(str)){
                break;
            } "0".equals(str) "0".equals "0" str {
                break;
            } break; char[] c = str.toCharArray(); c str.toCharArray() str.toCharArray str int sum = 0; sum 0 for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            } int i = 0; int i = 0; i 0 i < c.length i c.length c c.length i++ i++ i {
                sum += c[i] - '0';
            } {
                sum += c[i] - '0';
            } sum += c[i] - '0' sum c[i] - '0' c[i] c i '0' ln(sum) ln sum public static void main(String[] args) {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args public static void pr(Object o) {
        System.out.print(o);
    } pr {
        System.out.print(o);
    } System.out.print(o) System.out.print System.out System System.out o Object o o public static void ln(Object o) {
        System.out.println(o);
    } ln {
        System.out.println(o);
    } System.out.println(o) System.out.println System.out System System.out o Object o o public static void ln() {
        System.out.println();
    } ln {
        System.out.println();
    } System.out.println() System.out.println System.out System System.out
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
        while (true) {
            String str = sc.nextLine();
            if("0".equals(str)){
                break;
            }
            char[] c = str.toCharArray();
            int sum = 0;
            for (int i = 0; i < c.length; i++) {
                sum += c[i] - '0';
            }
            ln(sum);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}
