import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	} run {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		} true {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		} String str = scan.next(); str scan.next() scan.next scan if (str.equals("0")) break; str.equals("0") str.equals str "0" break; char[] cnum = str.toCharArray(); cnum str.toCharArray() str.toCharArray str int sum = 0; sum 0 for (char c : cnum) {
				sum += Character.getNumericValue(c);
			} char c cnum {
				sum += Character.getNumericValue(c);
			} {
				sum += Character.getNumericValue(c);
			} sum += Character.getNumericValue(c) sum Character.getNumericValue(c) Character.getNumericValue Character c System.out.println(sum) System.out.println System.out System System.out sum public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String str = scan.next();
			if (str.equals("0")) break;
			char[] cnum = str.toCharArray();
			int sum = 0;
			for (char c : cnum) {
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}