import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} Main public static final String EOL = System.getProperty("line.separator"); EOL System.getProperty("line.separator") System.getProperty System "line.separator" public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    } exec {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	} true {
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	} String l = br.readLine(); l br.readLine() br.readLine br if(l.equals("0"))
    			break; l.equals("0") l.equals l "0" break; int sum = 0; sum 0 for(char c : l.toCharArray()) {
    			sum += c;
    		} char c l.toCharArray() l.toCharArray l {
    			sum += c;
    		} {
    			sum += c;
    		} sum += c sum c out.println(sum - ('0'*l.length())) out.println out sum - ('0'*l.length()) sum ('0'*l.length()) '0' l.length() l.length l out.flush() out.flush out public static void main(String[] args) throws IOException {
    	new Main().exec();
    } main {
    	new Main().exec();
    } new Main().exec() new Main().exec new Main() String[] args args public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static final String EOL = System.getProperty("line.separator");
    public void exec() throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	PrintWriter out = new PrintWriter(System.out);
    	while (true){
        	String l = br.readLine();
    		if(l.equals("0"))
    			break;
    		int sum = 0;
    		for(char c : l.toCharArray()) {
    			sum += c;
    		}
    		out.println(sum - ('0'*l.length()));
    	}
        out.flush();
    }
 
    public static void main(String[] args) throws IOException {
    	new Main().exec();
    }
}