import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        }
    }
} import java.util.*; util.* java import java.text.*; text.* java class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        }
    }
} Main public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        } ; {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        } {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        } char [] cs = sc.nextLine().toCharArray(); cs sc.nextLine().toCharArray() sc.nextLine().toCharArray sc.nextLine() sc.nextLine sc if(cs[0] == '0') break; cs[0] == '0' cs[0] cs 0 '0' break; int s = 0; s 0 for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            } int i = 0; int i = 0; i 0 i < cs.length i cs.length cs cs.length i++ i++ i {
                s += cs[i] - '0';
            } {
                s += cs[i] - '0';
            } s += cs[i] - '0' s cs[i] - '0' cs[i] cs i '0' System.out.println(s) System.out.println System.out System System.out s String[]args args
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            char [] cs = sc.nextLine().toCharArray();
            if(cs[0] == '0') break;
            int s = 0;
            for(int i = 0; i < cs.length; i++) {
                s += cs[i] - '0';
            }
            System.out.println(s);
        }
    }
}