import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    }
} Main public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    } main {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    } Scanner scn = new Scanner(System.in); scn new Scanner(System.in) while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        } true {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        } String str = scn.next(); str scn.next() scn.next scn if(str.equals("0")) {
                break;
            } str.equals("0") str.equals str "0" {
                break;
            } break; int s = 0; s 0 char[] ary = str.toCharArray(); ary str.toCharArray() str.toCharArray str for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            } char elm ary {
                s += Integer.parseInt(elm + "");
            } {
                s += Integer.parseInt(elm + "");
            } s += Integer.parseInt(elm + "") s Integer.parseInt(elm + "") Integer.parseInt Integer elm + "" elm "" System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        while(true) {
            String str = scn.next();
            if(str.equals("0")) {
                break;
            }
            int s = 0;
            char[] ary = str.toCharArray();
            for(char elm : ary) {
                s += Integer.parseInt(elm + "");
            }
            System.out.println(s);
        }
    }
}