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

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

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			
			String input;
			for (;;) {
				input = reader.readLine();
				if (input.equals("0")) break;
				char ch;
				int sum = 0;
				for (int i = 0; i < input.length(); i++) {
					ch = input.charAt(i);
					sum += Character.getNumericValue(ch);
				}
				System.out.println(sum);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}