import java.io.*;

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

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