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

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    }

} 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 {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    }

} Main public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    } main {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    } try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        } {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String line; line int sum=0; sum 0 while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            } (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            } if(line.equals("0"))break; line.equals("0") line.equals line "0" break; sum=0 sum 0 for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	} int i=0; int i=0; i 0 i<line.length() i line.length() line.length line i++ i++ i {
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	} {
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	} sum+=Integer.parseInt(line.substring(i, i+1)) sum Integer.parseInt(line.substring(i, i+1)) Integer.parseInt Integer line.substring(i, i+1) line.substring line i i+1 i 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    }

} public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    }

} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int sum=0;
            while ((line = br.readLine()) != null) {
            	if(line.equals("0"))break;
            	sum=0;
            	for(int i=0;i<line.length();i++){
            		sum+=Integer.parseInt(line.substring(i, i+1));
            	}
            	System.out.println(sum);
            }
        }
    }

}