import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    }
    
    public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    }
} import java.util.*; util.* java public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    }
    
    public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    }
} Main private static final Scanner scn = new Scanner(System.in); scn new Scanner(System.in) public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    } main {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    } String str; str while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        } true {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        } str = scn.next() str scn.next() scn.next scn if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            } str.length() == 1 && str.charAt(0) == '0' str.length() == 1 str.length() str.length str 1 str.charAt(0) == '0' str.charAt(0) str.charAt str 0 '0' {
                break;
            } break; System.out.println(calcSum(str)) System.out.println System.out System System.out calcSum(str) calcSum str String[] args args public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    } calcSum {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    } int c = 0; c 0 char[] ary = str.toCharArray(); ary str.toCharArray() str.toCharArray str for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        } char elm ary {
            c += Integer.parseInt(elm + "");
        } {
            c += Integer.parseInt(elm + "");
        } c += Integer.parseInt(elm + "") c Integer.parseInt(elm + "") Integer.parseInt Integer elm + "" elm "" return c; c String str str public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    }
    
    public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    }
} public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    }
    
    public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    }
} Main
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        String str;
        while(true) {
            str = scn.next();
            if(str.length() == 1 && str.charAt(0) == '0') {
                break;
            }
            System.out.println(calcSum(str));
        }
    }
    
    public static int calcSum(String str) {
        int c = 0;
        char[] ary = str.toCharArray();
        for(char elm : ary) {
            c += Integer.parseInt(elm + "");
        }
        return c;
    }
}