import java.util.Scanner;

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

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	} main {
		Scanner sc = new Scanner(System.in);

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String str = sc.nextLine();

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		} true {
			String str = sc.nextLine();

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		} String str = sc.nextLine(); str sc.nextLine() sc.nextLine sc if (str.equals("0"))
				break; str.equals("0") str.equals str "0" break; char[] sen = str.toCharArray(); sen str.toCharArray() str.toCharArray str int sum = 0; sum 0 for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			} int i = 0; int i = 0; i 0 i<sen.length i sen.length sen sen.length i++ i++ i {
				sum += Character.getNumericValue(sen[i]);
			} {
				sum += Character.getNumericValue(sen[i]);
			} sum += Character.getNumericValue(sen[i]) sum Character.getNumericValue(sen[i]) Character.getNumericValue Character sen[i] sen 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 sc = new Scanner(System.in);

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

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

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

			if (str.equals("0"))
				break;
			char[] sen = str.toCharArray();
			int sum = 0;

			for (int i = 0; i<sen.length; i++) {
				sum += Character.getNumericValue(sen[i]);
			}
			System.out.println(sum);
		}
	}
}
