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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	}
} 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[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	} main {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<String> inputs = new ArrayList<>(); inputs new ArrayList<>() while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		} true {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		} String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc if(input.equals("0")) break; input.equals("0") input.equals input "0" break; inputs.add(input) inputs.add inputs input sc.close() sc.close sc for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		} String input inputs {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		} {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		} int i = 0; i 0 if(input.charAt(0) == '-') i = 1; input.charAt(0) == '-' input.charAt(0) input.charAt input 0 '-' i = 1 i 1 int ans = 0; ans 0 for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			} ; i < input.length() i input.length() input.length input i++ i++ i {
				ans += Character.getNumericValue(input.charAt(i));
			} {
				ans += Character.getNumericValue(input.charAt(i));
			} ans += Character.getNumericValue(input.charAt(i)) ans Character.getNumericValue(input.charAt(i)) Character.getNumericValue Character input.charAt(i) input.charAt input i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> inputs = new ArrayList<>();

		while(true) {

			String input = sc.nextLine();
			if(input.equals("0")) break;

			inputs.add(input);

		}
		sc.close();

		for(String input : inputs) {

			int i = 0;

			if(input.charAt(0) == '-') i = 1;

			int ans = 0;
			for (; i < input.length(); i++) {
				ans += Character.getNumericValue(input.charAt(i));
			}

			System.out.println(ans);
		}
	}
}