import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int sum;
        String str;
        String[] strArray;
        Scanner sc = new Scanner(System.in);
        str = sc.next();

        while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        int sum;
        String str;
        String[] strArray;
        Scanner sc = new Scanner(System.in);
        str = sc.next();

        while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        }
    }
} Main public static void main(String[] args) {
        int sum;
        String str;
        String[] strArray;
        Scanner sc = new Scanner(System.in);
        str = sc.next();

        while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        }
    } main {
        int sum;
        String str;
        String[] strArray;
        Scanner sc = new Scanner(System.in);
        str = sc.next();

        while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        }
    } int sum; sum String str; str String[] strArray; strArray Scanner sc = new Scanner(System.in); sc new Scanner(System.in) str = sc.next() str sc.next() sc.next sc while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        } str.charAt(0) != '0' str.charAt(0) str.charAt str 0 '0' {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        } strArray = str.split("") strArray str.split("") str.split str "" sum = 0 sum 0 for(String s : strArray) 
                sum += Integer.parseInt(s); String s strArray sum += Integer.parseInt(s); sum += Integer.parseInt(s) sum Integer.parseInt(s) Integer.parseInt Integer s System.out.println(sum) System.out.println System.out System System.out sum str = sc.next() str sc.next() sc.next sc String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int sum;
        String str;
        String[] strArray;
        Scanner sc = new Scanner(System.in);
        str = sc.next();

        while (str.charAt(0) != '0') {
            strArray = str.split("");
            sum = 0;
            for(String s : strArray) 
                sum += Integer.parseInt(s);
            System.out.println(sum);
            str = sc.next();
        }
    }
}
