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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	}
} 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) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	}
} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuffer sb = new StringBuffer(); sb new StringBuffer() while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		} true {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		} String input = br.readLine(); input br.readLine() br.readLine br if ("0".equals(input)) {
				break;
			} "0".equals(input) "0".equals "0" input {
				break;
			} break; int sum = 0; sum 0 for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			} int i =0; int i =0; i 0 i < input.length() i input.length() input.length input i++ i++ i {
				sum += Integer.parseInt(input.substring(i, i+1));
			} {
				sum += Integer.parseInt(input.substring(i, i+1));
			} 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 sb.append(sum + "\n") sb.append sb sum + "\n" sum "\n" System.out.print(sb.toString()) System.out.print System.out System System.out sb.toString() sb.toString sb String[] args args public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	}
} public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();

		while (true) {
			String input = br.readLine();
			if ("0".equals(input)) {
				break;
			}
			int sum = 0;
			for (int i =0; i < input.length(); i++) {
				sum += Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(sum + "\n");
		}
		System.out.print(sb.toString());
	}
}