import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	} main {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		} scanner.hasNext() scanner.hasNext scanner {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		} String str = scanner.nextLine(); str scanner.nextLine() scanner.nextLine scanner int sum = 0; sum 0 if (str.equals("0")) {
				break;
			} str.equals("0") str.equals str "0" {
				break;
			} break; for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			} int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
				sum += str.charAt(i) - '0';
			} {
				sum += str.charAt(i) - '0';
			} sum += str.charAt(i) - '0' sum str.charAt(i) - '0' str.charAt(i) str.charAt str i '0' 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) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
} public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			String str = scanner.nextLine();
			int sum = 0;
			if (str.equals("0")) {
				break;
			}
			for (int i = 0; i < str.length(); i++) {
				sum += str.charAt(i) - '0';
			}
			System.out.println(sum);
		}
	}
}