import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    }
} Main public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str; str ArrayList<Integer> Ans = new ArrayList<Integer>(); Ans new ArrayList<Integer>() while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    } (str = br.readLine()) != null (str = br.readLine()) str br.readLine() br.readLine br null {
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    } String temp[] = str.split(""); temp str.split("") str.split str "" int sum = 0; sum 0 for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        } int i =0; int i =0; i 0 i<temp.length i temp.length temp temp.length i++ i++ i {
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        } {
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        } int num = Integer.parseInt(temp[i]); num Integer.parseInt(temp[i]) Integer.parseInt Integer temp[i] temp i sum += num sum num if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } Integer.parseInt(temp[0]) == 0 Integer.parseInt(temp[0]) Integer.parseInt Integer temp[0] temp 0 0 {
                            break;
                        } break; Ans.add(sum) Ans.add Ans sum for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    } int i=0; int i=0; i 0 i<Ans.size() i Ans.size() Ans.size Ans i++ i++ i {
                        System.out.println(Ans.get(i));
                    } {
                        System.out.println(Ans.get(i));
                    } System.out.println(Ans.get(i)) System.out.println System.out System System.out Ans.get(i) Ans.get Ans i String[] args args public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    }
} public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    }
} Main
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        ArrayList<Integer> Ans = new ArrayList<Integer>();

                    while((str = br.readLine()) != null){
                        String temp[] = str.split("");
                        int sum = 0;
                        for(int i =0;i<temp.length;i++){
                            int num = Integer.parseInt(temp[i]);
                            sum += num;
                        }
                        if(Integer.parseInt(temp[0]) == 0){
                            break;
                        } 
                        Ans.add(sum);
                    }

                    for(int i=0;i<Ans.size();i++){
                        System.out.println(Ans.get(i));
                    }


    }
}