import java.util.*;

public class Main {

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

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

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

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

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

} public class Main {

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

} Main
import java.util.*;

public class Main {

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

}
