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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		} true {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		} String str = br.readLine(); str br.readLine() br.readLine br if ("0".equals(str)) {
				break;
			} "0".equals(str) "0".equals "0" str {
				break;
			} break; int len = str.length(); len str.length() str.length str int sum = 0; sum 0 for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			} int i = 0; int i = 0; i 0 i < len i len i++ i++ i {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			} {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			} int n = Integer.parseInt(String.valueOf(str.charAt(i))); n Integer.parseInt(String.valueOf(str.charAt(i))) Integer.parseInt Integer String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i sum += n sum n 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) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String str = br.readLine();
			if ("0".equals(str)) {
				break;
			}
			int len = str.length();
			int sum = 0;
			for (int i = 0; i < len; i++) {
				int n = Integer.parseInt(String.valueOf(str.charAt(i)));
				sum += n;
			}
			System.out.println(sum);
		}
	}
}