import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
}
 import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int i = 0 i 0 sum = 0; sum 0 String line = ""; line "" while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        } true {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        } line = sc.next() line sc.next() sc.next sc if(line.equals("0"))break; line.equals("0") line.equals line "0" break; sum = 0 sum 0 for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            } i = 0; i = 0 i 0 i < line.length() i line.length() line.length line i++ i++ i {
                sum += (line.charAt(i) - '0');
            } {
                sum += (line.charAt(i) - '0');
            } sum += (line.charAt(i) - '0') sum (line.charAt(i) - '0') line.charAt(i) line.charAt line i '0' System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0, sum = 0;
        String line = "";
        while (true) {
            line = sc.next();
            if(line.equals("0"))break;
            sum = 0;
            for (i = 0; i < line.length(); i++) {
                sum += (line.charAt(i) - '0');
            }
            System.out.println(sum);
        }
    }
}

