import java.util.Scanner;

public class Main {

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

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

	}

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

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

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

	}

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

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

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

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		} sc.hasNext() sc.hasNext sc {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		} String x = sc.next(); x sc.next() sc.next sc int sum = 0; sum 0 char[] str1 = x.toCharArray(); str1 x.toCharArray() x.toCharArray x for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			} int i = 0; int i = 0; i 0 i < str1.length i str1.length str1 str1.length i++ i++ i {
				sum += Character.getNumericValue(str1[i]);
			} {
				sum += Character.getNumericValue(str1[i]);
			} sum += Character.getNumericValue(str1[i]) sum Character.getNumericValue(str1[i]) Character.getNumericValue Character str1[i] str1 i if (x.equals("0")) {
				break;
			} x.equals("0") x.equals x "0" {
				break;
			} break; 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) {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

	}

} public class Main {

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

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

	}

} Main
import java.util.Scanner;

public class Main {

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

		while (sc.hasNext()) {
			String x = sc.next();
			int sum = 0;
			char[] str1 = x.toCharArray();
			for (int i = 0; i < str1.length; i++) {
				sum += Character.getNumericValue(str1[i]);
			}

			if (x.equals("0")) {
				break;
			}
			System.out.println(sum);
		}

	}

}