import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		}
	} main {

		Scanner scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			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;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		} true {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			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;
			} break; String[] strArry = str.split(""); strArry str.split("") str.split str "" int x = 0; x 0 int sum = 0; sum 0 for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			} int i = 0; int i = 0; i 0 i < strArry.length i strArry.length strArry strArry.length i++ i++ i {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			} {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			} x = Integer.parseInt(strArry[i]) x Integer.parseInt(strArry[i]) Integer.parseInt Integer strArry[i] strArry i sum = sum + x sum sum + x sum x 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 scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		while (true) {

			String str = scan.next();

			if (str.equals("0")) {
				break;
			}

			// strArry????????????????????????????´?
			String[] strArry = str.split("");

			
			int x = 0;
			int sum = 0;
			for (int i = 0; i < strArry.length; i++) {
				//??´??°???????????????x?????£??\
				x = Integer.parseInt(strArry[i]);
				sum = sum + x;
			}
			
			System.out.println(sum);
		}
	}
}