import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s;

        for (s = input.next(); !s.equals("0"); s = input.next()){
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s;

        for (s = input.next(); !s.equals("0"); s = input.next()){
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s;

        for (s = input.next(); !s.equals("0"); s = input.next()){
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        }
    } main {
        Scanner input = new Scanner(System.in);
        String s;

        for (s = input.next(); !s.equals("0"); s = input.next()){
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        }
    } Scanner input = new Scanner(System.in); input new Scanner(System.in) String s; s for (s = input.next(); !s.equals("0"); s = input.next()){
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        } s = input.next(); s = input.next() s input.next() input.next input !s.equals("0") s.equals("0") s.equals s "0" s = input.next() s = input.next() s input.next() input.next input {
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        } {
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        } int sum = 0; sum 0 for (char c : s.toCharArray()){
                sum += c - '0';
            } char c s.toCharArray() s.toCharArray s {
                sum += c - '0';
            } {
                sum += c - '0';
            } sum += c - '0' sum c - '0' c '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s;

        for (s = input.next(); !s.equals("0"); s = input.next()){
            int sum = 0;
            for (char c : s.toCharArray()){
                sum += c - '0';
            }
            System.out.println(sum);
        }
    }
}