import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        }
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        }
    }
} Main public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        }
    } main {
        Scanner scan = new Scanner(System.in);
        while (true) {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        } true {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        } String number = scan.nextLine(); number scan.nextLine() scan.nextLine scan int num = 0; num 0 if (number.equals("0")) {
                break;
            } number.equals("0") number.equals number "0" {
                break;
            } break; for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            } int i = 0; int i = 0; i 0 i < number.length() i number.length() number.length number i++ i++ i {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            } {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            } char ch = number.charAt(i); ch number.charAt(i) number.charAt number i num += Character.getNumericValue(ch) num Character.getNumericValue(ch) Character.getNumericValue Character ch System.out.println(num) System.out.println System.out System System.out num String args[] args
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true) {
            String number = scan.nextLine();
            int num = 0;
            if (number.equals("0")) {
                break;
            }
            for(int i = 0; i < number.length(); i++) {
                char ch = number.charAt(i);
                num += Character.getNumericValue(ch);
            }
                System.out.println(num);
        }
    }
}