import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x = sc.nextLine(); x sc.nextLine() sc.nextLine sc int temp = 0; temp 0 while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		} true {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		} if (x.equals("0")) {
				break;
			} x.equals("0") x.equals x "0" {
				break;
			} break; for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
				temp += Integer.parseInt(x.substring(i, i + 1));
			} {
				temp += Integer.parseInt(x.substring(i, i + 1));
			} temp += Integer.parseInt(x.substring(i, i + 1)) temp Integer.parseInt(x.substring(i, i + 1)) Integer.parseInt Integer x.substring(i, i + 1) x.substring x i i + 1 i 1 System.out.println(temp) System.out.println System.out System System.out temp temp = 0 temp 0 x = sc.nextLine() x sc.nextLine() sc.nextLine sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		int temp = 0;
		while (true) {
			if (x.equals("0")) {
				break;
			}
			for (int i = 0; i < x.length(); i++) {
				temp += Integer.parseInt(x.substring(i, i + 1));
			}
			System.out.println(temp);
			temp = 0;
			x = sc.nextLine();
		}
	}
}
