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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}

} 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) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}

} Main public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		} catch (IOException e) {
			System.out.println(e);
		} IOException e {
			System.out.println(e);
		} System.out.println(e) System.out.println System.out System System.out e {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			} true {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			} String line = reader.readLine(); line reader.readLine() reader.readLine reader if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				} line.equals("0") line.equals line "0" {
					break;
				} break; {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				} int length = line.length(); length line.length() line.length line int[] n = new int[length]; n new int[length] length int sum = 0; sum 0 for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					} int i = 0; int i = 0; i 0 i < length i length i++ i++ i {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					} {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					} n[i] = line.charAt(i) - '0' n[i] n i line.charAt(i) - '0' line.charAt(i) line.charAt line i '0' sum += n[i] sum n[i] n i 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) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}

} public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}

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

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try {
			while (true) {
				String line = reader.readLine();
				if (line.equals("0")) {
					break;
				} else {
					int length = line.length();
					int[] n = new int[length];
					int sum = 0;
					for (int i = 0; i < length; i++) {
						n[i] = line.charAt(i) - '0';
						sum += n[i];
					}
					System.out.println(sum);
				}
			}
		} catch (IOException e) {
			System.out.println(e);
		}
	}

}
