import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    }
} Main public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    } main {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        } true {
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        } String line = br.readLine(); line br.readLine() br.readLine br if(line.equals("0")){
                break;
            } line.equals("0") line.equals line "0" {
                break;
            } break; char[] charArray = line.toCharArray(); charArray line.toCharArray() line.toCharArray line int total = 0; total 0 for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            } int i = 0; int i = 0; i 0 i < charArray.length i charArray.length charArray charArray.length i++ i++ i {
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            } {
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            } char ch = charArray[i]; ch charArray[i] charArray i total += Character.getNumericValue(ch) total Character.getNumericValue(ch) Character.getNumericValue Character ch System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        while(true){
            String line = br.readLine();
            if(line.equals("0")){
                break;
            }
            
            char[] charArray = line.toCharArray();
            int total = 0;
            for(int i = 0; i < charArray.length; i++){
                char ch = charArray[i];
                total += Character.getNumericValue(ch);
            }
            
            System.out.println(total);
        }
    }
}