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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder builder = new StringBuilder(); builder new StringBuilder() String str; str while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		} !(str = br.readLine()).equals("0") (str = br.readLine()).equals("0") (str = br.readLine()).equals (str = br.readLine()) str br.readLine() br.readLine br "0" {
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		} int sum=0; sum 0 for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				sum += Integer.parseInt(str.substring(i, i+1));
			} {
				sum += Integer.parseInt(str.substring(i, i+1));
			} sum += Integer.parseInt(str.substring(i, i+1)) sum Integer.parseInt(str.substring(i, i+1)) Integer.parseInt Integer str.substring(i, i+1) str.substring str i i+1 i 1 builder.append(sum + "\n") builder.append builder sum + "\n" sum "\n" builder.delete(builder.length() -1 , builder.length()) builder.delete builder builder.length() -1 builder.length() builder.length builder 1 builder.length() builder.length builder System.out.println(builder) System.out.println System.out System System.out builder String[] args args public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();

		String str;
		while(!(str = br.readLine()).equals("0")){
			int sum=0;
			for(int i=0; i<str.length();i++){
				sum += Integer.parseInt(str.substring(i, i+1));
			}
			builder.append(sum + "\n");
		}
		builder.delete(builder.length() -1 , builder.length());

		System.out.println(builder);
	}
}