import java.util.Scanner;

public class Main{

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

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

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

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

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

} public class Main{

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

} Main
import java.util.Scanner;

public class Main{

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

}

