import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	}

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

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	}

} Main public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	} main {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	} @SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		} true {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		} String ins = scan.nextLine(); ins scan.nextLine() scan.nextLine scan if (ins.equals("0"))
				break; ins.equals("0") ins.equals ins "0" break; int ans = 0; ans 0 for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0'); int i = 0; int i = 0; i 0 i < ins.length() i ins.length() ins.length ins i++ i++ i ans += (int) (ins.charAt(i) - '0'); ans += (int) (ins.charAt(i) - '0') ans (int) (ins.charAt(i) - '0') ins.charAt(i) ins.charAt ins i '0' System.out.println(ans) System.out.println System.out System System.out ans System.exit(0) System.exit System 0 String[] args args public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	}

} public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (true) {
			String ins = scan.nextLine();
			if (ins.equals("0"))
				break;
			int ans = 0;
			for (int i = 0; i < ins.length(); i++)
				ans += (int) (ins.charAt(i) - '0');
			System.out.println(ans);
		}

		System.exit(0);
	}

}