import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,ans;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        }
        System.out.flush();
    }
} import java.io.*; io.* java import java.util.Arrays; Arrays java.util class Main{
    public static void main(String[] args) throws IOException {
        int i,ans;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        }
        System.out.flush();
    }
} Main public static void main(String[] args) throws IOException {
        int i,ans;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        }
        System.out.flush();
    } main {
        int i,ans;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        }
        System.out.flush();
    } int i i ans; ans String str; str BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) for(;;){
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        } ; {
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        } {
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        } str = in.readLine() str in.readLine() in.readLine in if(str.equals("0")) break; str.equals("0") str.equals str "0" break; char[] c = str.toCharArray(); c str.toCharArray() str.toCharArray str ans=0 ans 0 for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            } i=0; i=0 i 0 i<str.length() i str.length() str.length str i++ i++ i {
                ans+=Integer.parseInt(String.valueOf(c[i]));
            } {
                ans+=Integer.parseInt(String.valueOf(c[i]));
            } ans+=Integer.parseInt(String.valueOf(c[i])) ans Integer.parseInt(String.valueOf(c[i])) Integer.parseInt Integer String.valueOf(c[i]) String.valueOf String c[i] c i System.out.println(ans) System.out.println System.out System System.out ans System.out.flush() System.out.flush System.out System System.out String[] args args
import java.io.*;
import java.util.Arrays;
class Main{
    public static void main(String[] args) throws IOException {
        int i,ans;
        String str;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(;;){
            str = in.readLine();
            if(str.equals("0")) break;
            char[] c = str.toCharArray();
            ans=0;
            for(i=0;i<str.length();i++){
                ans+=Integer.parseInt(String.valueOf(c[i]));
            }
            System.out.println(ans);
        }
        System.out.flush();
    }
}