import java.util.Scanner;                                                   

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        }
} Main public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        } main {
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        } Scanner in = new Scanner(System.in); in new Scanner(System.in) while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        } true {
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        } String a = in.nextLine(); a in.nextLine() in.nextLine in if(a.equals("0")){
                break;
            } a.equals("0") a.equals a "0" {
                break;
            } break; int s = 0; s 0 String sary[] = a.split(""); sary a.split("") a.split a "" for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            } int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
                s += Integer.parseInt(sary[i]);
            } {
                s += Integer.parseInt(sary[i]);
            } s += Integer.parseInt(sary[i]) s Integer.parseInt(sary[i]) Integer.parseInt Integer sary[i] sary i System.out.println(s) System.out.println System.out System System.out s String[] args args public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        }
} public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        }
} Main
import java.util.Scanner;                                                   

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        }
}