import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    }
} import java.util.*; util.* java public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    } main {
        Main main = new Main();
        main.solv();
    } Main main = new Main(); main new Main() main.solv() main.solv main String[] args args private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    } solv {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        } true {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        } char[] cs = input.nextLine().toCharArray(); cs input.nextLine().toCharArray() input.nextLine().toCharArray input.nextLine() input.nextLine input if (cs.length <= 0 || cs[0] == '0') break; cs.length <= 0 || cs[0] == '0' cs.length <= 0 cs.length cs cs.length 0 cs[0] == '0' cs[0] cs 0 '0' break; int sum = 0; sum 0 for (int i = 0; i < cs.length; i++) sum += cs[i] - '0'; int i = 0; int i = 0; i 0 i < cs.length i cs.length cs cs.length i++ i++ i sum += cs[i] - '0'; sum += cs[i] - '0' sum cs[i] - '0' cs[i] cs i '0' System.out.println(sum) System.out.println System.out System System.out sum public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    }
} public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    }
} Main
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        while (true) {
            char[] cs = input.nextLine().toCharArray();
            if (cs.length <= 0 || cs[0] == '0') break;
            int sum = 0;
            for (int i = 0; i < cs.length; i++) sum += cs[i] - '0';
            System.out.println(sum);
        }
    }
}