import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	}
} Main public static void main(String[] args) {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	} main {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	} String a = ""; a "" int sum; sum Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		} true {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		} sum = 0 sum 0 a = sc.nextLine() a sc.nextLine() sc.nextLine sc if (a.equals("0")) {
				break;
			} a.equals("0") a.equals a "0" {
				break;
			} break; for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			} int i = 0; int i = 0; i 0 i < a.length() i a.length() a.length a i++ i++ i {
				sum += Character.getNumericValue(a.charAt(i));
			} {
				sum += Character.getNumericValue(a.charAt(i));
			} sum += Character.getNumericValue(a.charAt(i)) sum Character.getNumericValue(a.charAt(i)) Character.getNumericValue Character a.charAt(i) a.charAt a i System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	}
} public class Main {
	public static void main(String[] args) {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		String a = "";
		int sum;

		Scanner sc = new Scanner(System.in);

		while (true) {
			sum = 0;
			a = sc.nextLine();

			if (a.equals("0")) {
				break;
			}

			for (int i = 0; i < a.length(); i++) {
				sum += Character.getNumericValue(a.charAt(i));
			}
			System.out.println(sum);
		}

		sc.close();
	}
}

