import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		} true {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		} String string = scanner.nextLine(); string scanner.nextLine() scanner.nextLine scanner if (string.equals("0")) {
				break;
			} string.equals("0") string.equals string "0" {
				break;
			} break; int sum = 0; sum 0 for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			} int i=0; int i=0; i 0 i<string.length() i string.length() string.length string i++ i++ i {
				sum += string.charAt(i)-48;
			} {
				sum += string.charAt(i)-48;
			} sum += string.charAt(i)-48 sum string.charAt(i)-48 string.charAt(i) string.charAt string i 48 System.out.println(sum) System.out.println System.out System System.out sum scanner.close() scanner.close scanner String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String string = scanner.nextLine();
			if (string.equals("0")) {
				break;
			}
			int sum = 0;
			for(int i=0;i<string.length();i++) {
				sum += string.charAt(i)-48;
			}
			System.out.println(sum);
		}
		scanner.close();
	}
}
