import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	} main {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		} s.hasNext() s.hasNext s {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		} char[] chars = s.next().toCharArray(); chars s.next().toCharArray() s.next().toCharArray s.next() s.next s if (chars[0] == '0') return; chars[0] == '0' chars[0] chars 0 '0' return; int sum = 0; sum 0 for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			} int i = 0; int i = 0; i 0 i < chars.length i chars.length chars chars.length ++i ++i i {
				sum += Character.getNumericValue(chars[i]);
			} {
				sum += Character.getNumericValue(chars[i]);
			} sum += Character.getNumericValue(chars[i]) sum Character.getNumericValue(chars[i]) Character.getNumericValue Character chars[i] chars i 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 s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while (s.hasNext()) {
			char[] chars = s.next().toCharArray();
			if (chars[0] == '0') return;
			int sum = 0;
			for (int i = 0; i < chars.length; ++i) {
				sum += Character.getNumericValue(chars[i]);
			}
			System.out.println(sum);
		}
	}
}