import static java.lang.System.out;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String num = scan.next();
        String[] numbers = num.split("");
        int ans = 0;
        while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        }
    }   
}       import static java.lang.System.out; import static java.lang.System.out; import static java.lang.System.out; import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String num = scan.next();
        String[] numbers = num.split("");
        int ans = 0;
        while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        }
    }   
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String num = scan.next();
        String[] numbers = num.split("");
        int ans = 0;
        while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        }
    } main {
        Scanner scan = new Scanner(System.in);
        String num = scan.next();
        String[] numbers = num.split("");
        int ans = 0;
        while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String num = scan.next(); num scan.next() scan.next scan String[] numbers = num.split(""); numbers num.split("") num.split num "" int ans = 0; ans 0 while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        } !numbers[0].equals("0") numbers[0].equals("0") numbers[0].equals numbers[0] numbers 0 "0" {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        } for (String n : numbers) {
                ans += Integer.parseInt(n);
            } String n numbers {
                ans += Integer.parseInt(n);
            } {
                ans += Integer.parseInt(n);
            } ans += Integer.parseInt(n) ans Integer.parseInt(n) Integer.parseInt Integer n out.println(ans) out.println out ans num = scan.next() num scan.next() scan.next scan numbers = num.split("") numbers num.split("") num.split num "" ans = 0 ans 0 String[] args args
import static java.lang.System.out;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String num = scan.next();
        String[] numbers = num.split("");
        int ans = 0;
        while (!numbers[0].equals("0")) {
            for (String n : numbers) {
                ans += Integer.parseInt(n);
            }
            out.println(ans);
            num = scan.next();
            numbers = num.split("");
            ans = 0;
        }
    }   
}      