import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		char[] x;

		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		}
		stdIn.close();
	}
} import java.util.Scanner; Scanner java.util class Main {

	public static void main(String[] args) {

		char[] x;

		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		}
		stdIn.close();
	}
} Main public static void main(String[] args) {

		char[] x;

		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		}
		stdIn.close();
	} main {

		char[] x;

		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		}
		stdIn.close();
	} char[] x; x Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) boolean flag = true; flag true while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		} flag {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		} int sum = 0; sum 0 x = stdIn.nextLine().toCharArray() x stdIn.nextLine().toCharArray() stdIn.nextLine().toCharArray stdIn.nextLine() stdIn.nextLine stdIn if(x[0] == '0') {
				break;
			} x[0] == '0' x[0] x 0 '0' {
				break;
			} break; for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			} int j = 0; int j = 0; j 0 j < x.length j x.length x x.length j++ j++ j {
				sum += Character.getNumericValue(x[j]);
			} {
				sum += Character.getNumericValue(x[j]);
			} sum += Character.getNumericValue(x[j]) sum Character.getNumericValue(x[j]) Character.getNumericValue Character x[j] x j System.out.println(sum) System.out.println System.out System System.out sum stdIn.close() stdIn.close stdIn String[] args args
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		char[] x;

		Scanner stdIn = new Scanner(System.in);

		boolean flag = true;
		while (flag) {
			int sum = 0;
			x = stdIn.nextLine().toCharArray();
			if(x[0] == '0') {
				break;
			}

			for (int j = 0; j < x.length; j++) {
				sum += Character.getNumericValue(x[j]);
			}
			System.out.println(sum);
		}
		stdIn.close();
	}
}