import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	}
} import java.io.*; io.* java public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		} true {
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		} String line = reader.readLine(); line reader.readLine() reader.readLine reader int[] digit = new int[line.length()]; digit new int[line.length()] line.length() line.length line int result = 0; result 0 for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			} int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			} {
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			} digit[i] = Character.getNumericValue(line.charAt(i)) digit[i] digit i Character.getNumericValue(line.charAt(i)) Character.getNumericValue Character line.charAt(i) line.charAt line i result += digit[i] result digit[i] digit i if(result == 0){
				break;
			}else{
				System.out.println(result);
			} result == 0 result 0 {
				break;
			} break; {
				System.out.println(result);
			} System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	}
} public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	}
} Main
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = reader.readLine();
			int[] digit = new int[line.length()];
			int result = 0;
			for(int i = 0; i < line.length(); i++){
				digit[i] = Character.getNumericValue(line.charAt(i));
				result += digit[i];
			}
			if(result == 0){
				break;
			}else{
				System.out.println(result);
			}
		}
	}
}