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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			System.out.println(sum);
		} true {
			sum = 0;
			String input = in.readLine();
			if (input.equals("0")) {
				break;
			}
			size = (short) input.length();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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 char[] charNum = input.toCharArray(); charNum input.toCharArray() input.toCharArray input for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			} int i = 0; int i = 0; i 0 i < size i size i += 1 i += 1 i 1 {
				charNum[i] = input.charAt(i);
			} {
				charNum[i] = input.charAt(i);
			} charNum[i] = input.charAt(i) charNum[i] charNum i input.charAt(i) input.charAt input i for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			} int j = 0; int j = 0; j 0 j < size j size j += 1 j += 1 j 1 {
				sum += Short.parseShort(Character.toString(charNum[j]));
			} {
				sum += Short.parseShort(Character.toString(charNum[j]));
			} sum += Short.parseShort(Character.toString(charNum[j])) sum Short.parseShort(Character.toString(charNum[j])) Short.parseShort Short Character.toString(charNum[j]) Character.toString Character charNum[j] charNum j 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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			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();
			char[] charNum = input.toCharArray();
			for (int i = 0; i < size; i += 1) {
				charNum[i] = input.charAt(i);
			}
			for (int j = 0; j < size; j += 1) {
				sum += Short.parseShort(Character.toString(charNum[j]));
			}
			System.out.println(sum);
		}
	}
}