import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
} Main public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) try {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} IOException e {
			e.printStackTrace();
		} e.printStackTrace() e.printStackTrace e {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} List<Integer> ret = new ArrayList<Integer>(); ret new ArrayList<Integer>() do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true); true {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} String input = br.readLine(); input br.readLine() br.readLine br if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				} input.equals("0") input.equals input "0" {
					break;
				} break; {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				} int i i sum = 0; sum 0 for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					} i = 0; i = 0 i 0 i < input.length() i input.length() input.length input i++ i++ i {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					} {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					} sum = sum + Integer.parseInt(input.substring(i, i + 1)) sum sum + Integer.parseInt(input.substring(i, i + 1)) sum Integer.parseInt(input.substring(i, i + 1)) Integer.parseInt Integer input.substring(i, i + 1) input.substring input i i + 1 i 1 ret.add(sum) ret.add ret sum for (int num : ret) {
				System.out.println(num);
			} int num ret {
				System.out.println(num);
			} {
				System.out.println(num);
			} System.out.println(num) System.out.println System.out System System.out num String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			List<Integer> ret = new ArrayList<Integer>();
			do {
				String input = br.readLine();
				if (input.equals("0")) {
					break;
				} else {
					int i, sum = 0;
					for (i = 0; i < input.length(); i++) {
						sum = sum + Integer.parseInt(input.substring(i, i + 1));
					}
					ret.add(sum);
				}
			} while (true);

			for (int num : ret) {
				System.out.println(num);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}