import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	} main {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<String> lines = new ArrayList<String>(); lines new ArrayList<String>() int c = 0; c 0 while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		} true {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		} String next = sc.nextLine(); next sc.nextLine() sc.nextLine sc if (next.equals("0")) {
				break;
			} next.equals("0") next.equals next "0" {
				break;
			} break; lines.add(next) lines.add lines next c++ c for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		} int i = 0; int i = 0; i 0 i < c i c i++ i++ i {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		} {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		} String s = lines.get(i); s lines.get(i) lines.get lines i int sum = 0; sum 0 for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			} int j = 0; int j = 0; j 0 j < s.length() j s.length() s.length s j++ j++ j {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			} {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			} int in = Integer.parseInt(s.substring(j, j + 1)); in Integer.parseInt(s.substring(j, j + 1)) Integer.parseInt Integer s.substring(j, j + 1) s.substring s j j + 1 j 1 sum += in sum in 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) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	}

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		ArrayList<String> lines = new ArrayList<String>();
		int c = 0;

		while (true) {
			String next = sc.nextLine();

			if (next.equals("0")) {
				break;
			}
			lines.add(next);
			c++;
		}

		for (int i = 0; i < c; i++) {
			String s = lines.get(i);
			int sum = 0;
			for (int j = 0; j < s.length(); j++) {
				int in = Integer.parseInt(s.substring(j, j + 1));
				sum += in;
			}
			System.out.println(sum);
		}

	}

}