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));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	}
} 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));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	}
} Main public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	} main {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	} BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		} true {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		} try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			} 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 catch (NumberFormatException e) {
				System.out.println("");
			} NumberFormatException e {
				System.out.println("");
			} System.out.println("") System.out.println System.out System System.out "" {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} String x = reader.readLine(); x reader.readLine() reader.readLine reader if (x.equals("0")) {
					break;
				} x.equals("0") x.equals x "0" {
					break;
				} break; int sum = 0; sum 0 for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
					sum += x.charAt(i) - '0';
				} {
					sum += x.charAt(i) - '0';
				} sum += x.charAt(i) - '0' sum x.charAt(i) - '0' x.charAt(i) x.charAt x i '0' 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));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	}
} public class Main {
	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	}
} 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));

		while (true) {
			try {
				String x = reader.readLine();
				if (x.equals("0")) {
					break;
				}

				int sum = 0;
				for (int i = 0; i < x.length(); i++) {
					sum += x.charAt(i) - '0';
				}

				System.out.println(sum);

			} catch (IOException e) {
				System.out.println(e);
			} catch (NumberFormatException e) {
				System.out.println("");
			}
		}
	}
}
