import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	}

} Main public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	} main {

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<String> k = new ArrayList<String>(); k new ArrayList<String>() while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		} true {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc k.add(line) k.add k line if (line.equals("0")) {
				break;
			} line.equals("0") line.equals line "0" {
				break;
			} break; for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		} String string k {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		} {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		} if (string.equals("0")) {
				break;
			} string.equals("0") string.equals string "0" {
				break;
			} break; String[] lig = new String[string.length()]; lig new String[string.length()] string.length() string.length string for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			} int i = 0; int i = 0; i 0 i < string.length() i string.length() string.length string i++ i++ i {
				lig[i] = string.substring(i, i + 1);
			} {
				lig[i] = string.substring(i, i + 1);
			} lig[i] = string.substring(i, i + 1) lig[i] lig i string.substring(i, i + 1) string.substring string i i + 1 i 1 int sum = 0; sum 0 int[] v = new int[lig.length]; v new int[lig.length] lig.length lig lig.length for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			} int i = 0; int i = 0; i 0 i < lig.length i lig.length lig lig.length i++ i++ i {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			} {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			} v[i] = Integer.parseInt(lig[i]) v[i] v i Integer.parseInt(lig[i]) Integer.parseInt Integer lig[i] lig i sum += v[i] sum v[i] v i System.out.println(sum) System.out.println System.out System System.out sum String[] arges arges public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	}

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

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	}

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		List<String> k = new ArrayList<String>();
		while (true) {
			String line = sc.nextLine();
			k.add(line);
			if (line.equals("0")) {
				break;
			}
		}

		for (String string : k) {
			if (string.equals("0")) {
				break;
			}
			String[] lig = new String[string.length()];
			for (int i = 0; i < string.length(); i++) {
				lig[i] = string.substring(i, i + 1);
			}
			int sum = 0;
			int[] v = new int[lig.length];
			for (int i = 0; i < lig.length; i++) {
				v[i] = Integer.parseInt(lig[i]);
				sum += v[i];
			}
			System.out.println(sum);
		}

	}

}