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

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	}
} 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 in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) short size size sum; sum while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		} true {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		} sum = 0 sum 0 String input = in.readLine(); input in.readLine() in.readLine in if (input.equals("0")) {
				break;
			} input.equals("0") input.equals input "0" {
				break;
			} break; size = (short) input.length() size (short) input.length() input.length input for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			} int i = 0; int i = 0; i 0 i < size i size i += 1 i += 1 i 1 {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			} {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			} sum += Short.parseShort(Character.toString(input.charAt(i))) sum Short.parseShort(Character.toString(input.charAt(i))) Short.parseShort Short Character.toString(input.charAt(i)) Character.toString Character input.charAt(i) input.charAt input i 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 IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	}
} 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 in = new BufferedReader(new InputStreamReader(System.in));
		short size, sum;
		while (true) {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			for (int i = 0; i < size; i += 1) {
				sum += Short.parseShort(Character.toString(input.charAt(i)));
			}
			System.out.println(sum);
		}
	}
}