
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	}
} 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 a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	} main {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		} true {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		} String a = scanner.nextLine(); a scanner.nextLine() scanner.nextLine scanner if (a.equals("0"))
				break; a.equals("0") a.equals a "0" break; int sum = 0; sum 0 for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			} char b a.toCharArray() a.toCharArray a {
				sum += Integer.parseInt(String.valueOf(b));
			} {
				sum += Integer.parseInt(String.valueOf(b));
			} sum += Integer.parseInt(String.valueOf(b)) sum Integer.parseInt(String.valueOf(b)) Integer.parseInt Integer String.valueOf(b) String.valueOf String b System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	}
} Main

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String a = scanner.nextLine();
			if (a.equals("0"))
				break;
			int sum = 0;
			for (char b : a.toCharArray()) {
				sum += Integer.parseInt(String.valueOf(b));
			}
			System.out.println(sum);
		}
	}
}