import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	}

	public static void outSumOfNumbers(String numStr) {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[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);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	}

	public static void outSumOfNumbers(String numStr) {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		}
		
		System.out.println(sum);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	} main {
		Scanner sc = new Scanner(System.in);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String numStr; numStr while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		} true {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		} numStr = sc.next() numStr sc.next() sc.next sc if (numStr.equals("0"))
				break; numStr.equals("0") numStr.equals numStr "0" break; outSumOfNumbers(numStr) outSumOfNumbers numStr String[] args args public static void outSumOfNumbers(String numStr) {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		}
		
		System.out.println(sum);
	} outSumOfNumbers {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		}
		
		System.out.println(sum);
	} byte[] sbyte = new byte[numStr.length()]; sbyte new byte[numStr.length()] numStr.length() numStr.length numStr int sum = 0; sum 0 for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		} int i = 0; int i = 0; i 0 i < numStr.length() i numStr.length() numStr.length numStr i++ i++ i {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		} {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		} sbyte[i] = (byte) numStr.charAt(i) sbyte[i] sbyte i (byte) numStr.charAt(i) numStr.charAt numStr i sbyte[i] -= 48 sbyte[i] sbyte i 48 sum += sbyte[i] sum sbyte[i] sbyte i System.out.println(sum) System.out.println System.out System System.out sum String numStr numStr public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	}

	public static void outSumOfNumbers(String numStr) {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		}
		
		System.out.println(sum);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	}

	public static void outSumOfNumbers(String numStr) {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[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);
		String numStr;
		while (true) {
			numStr = sc.next();
			if (numStr.equals("0"))
				break;

			outSumOfNumbers(numStr);

		}

	}

	public static void outSumOfNumbers(String numStr) {
		byte[] sbyte = new byte[numStr.length()];
		int sum = 0;

		for (int i = 0; i < numStr.length(); i++) {
			sbyte[i] = (byte) numStr.charAt(i);
			sbyte[i] -= 48;
			sum += sbyte[i];
		}
		
		System.out.println(sum);
	}

}