import java.io.*;
import java.util.*;
 
class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        }
    }
}
  import java.io.*; io.* java import java.util.*; util.* java class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        }
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        }
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        } true {
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        } String str=br.readLine(); str br.readLine() br.readLine br if(str.equals("0")) break; str.equals("0") str.equals str "0" break; char[] c_array=str.toCharArray(); c_array str.toCharArray() str.toCharArray str int sum=0; sum 0 for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c)); char c c_array sum+=Integer.parseInt(String.valueOf(c)); sum+=Integer.parseInt(String.valueOf(c)) sum Integer.parseInt(String.valueOf(c)) Integer.parseInt Integer String.valueOf(c) String.valueOf String c System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.*;
import java.util.*;
 
class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String str=br.readLine();
            if(str.equals("0")) break;
            char[] c_array=str.toCharArray();
            int sum=0;
            for(char c:c_array) sum+=Integer.parseInt(String.valueOf(c));
            System.out.println(sum);
        }
    }
}
 