import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} Main public static Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	} main {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	} ArrayList<String> list = new ArrayList<String>(); list new ArrayList<String>() while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		} true {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		} String text = input(); text input() input if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			} text.equals("0") text.equals text "0" {

				break;

			} break; {

				list.add(text);

			} list.add(text) list.add list text for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		} int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		} {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		} String[] arrays = list.get(i).split(""); arrays list.get(i).split("") list.get(i).split list.get(i) list.get list i "" int sum = 0; sum 0 for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			} int j = 0; int j = 0; j 0 j < arrays.length j arrays.length arrays arrays.length j++ j++ j {

				sum += Integer.parseInt(arrays[j]);

			} {

				sum += Integer.parseInt(arrays[j]);

			} sum += Integer.parseInt(arrays[j]) sum Integer.parseInt(arrays[j]) Integer.parseInt Integer arrays[j] arrays j System.out.println(sum) System.out.println System.out System System.out sum sum = 0 sum 0 close() close String[] args args public static String input() {

		return scanner.nextLine();

	} input {

		return scanner.nextLine();

	} return scanner.nextLine(); scanner.nextLine() scanner.nextLine scanner public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	} close {

		if (scanner != null) {

			scanner.close();

		}
	} if (scanner != null) {

			scanner.close();

		} scanner != null scanner null {

			scanner.close();

		} scanner.close() scanner.close scanner public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<String> list = new ArrayList<String>();

		while (true) {

			String text = input();

			if (text.equals("0")) {

				break;

			} else {

				list.add(text);

			}
		}

		for (int i = 0; i < list.size(); i++) {

			String[] arrays = list.get(i).split("");

			int sum = 0;

			for (int j = 0; j < arrays.length; j++) {

				sum += Integer.parseInt(arrays[j]);

			}

			System.out.println(sum);
			sum = 0;

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}