import java.util.Scanner;

public class Main {

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	}

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

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	}

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	} main {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		} true {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc if (line.equals("0")) {
				break;
			} line.equals("0") line.equals line "0" {
				break;
			} break; int result = 0; result 0 for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			} int i = 0; int i = 0; i 0 i < line.length() i line.length() line.length line i++ i++ i {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			} {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			} String str = line.substring(i, i + 1); str line.substring(i, i + 1) line.substring line i i + 1 i 1 int n = Integer.parseInt(str); n Integer.parseInt(str) Integer.parseInt Integer str result += n result n System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	}

} public class Main {

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	}

} Main
import java.util.Scanner;

public class Main {

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	}

}