import java.util.*;

public class Main {

	public static void main(String[] args) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	}

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

	public static void main(String[] args) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	}

} Main public static void main(String[] args) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	} main {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	} int sum; sum String s; s Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		} true {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		} s = sc.next() s sc.next() sc.next sc sum = 0 sum 0 if (s.equals("0"))
				break; s.equals("0") s.equals s "0" break; for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
				sum += Integer.parseInt(""+ s.charAt(i));
			} {
				sum += Integer.parseInt(""+ s.charAt(i));
			} sum += Integer.parseInt(""+ s.charAt(i)) sum Integer.parseInt(""+ s.charAt(i)) Integer.parseInt Integer ""+ s.charAt(i) "" s.charAt(i) s.charAt s i if (!s.equals("0"))
				System.out.println(sum); !s.equals("0") s.equals("0") s.equals s "0" 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) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	}

} public class Main {

	public static void main(String[] args) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		int sum;
		String s;
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			sum = 0;
			if (s.equals("0"))
				break;
			for (int i = 0; i < s.length(); i++) {
				sum += Integer.parseInt(""+ s.charAt(i));
			}
			if (!s.equals("0"))
				System.out.println(sum);
		}
	}

}