

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	}
} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true); true {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} char[] firstInput = br.readLine().toCharArray(); firstInput br.readLine().toCharArray() br.readLine().toCharArray br.readLine() br.readLine br int[] num = new int[firstInput.length]; num new int[firstInput.length] firstInput.length firstInput firstInput.length char seconInput = 0; seconInput 0 for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			} int i = 0; int i = 0; i 0 i < firstInput.length i firstInput.length firstInput firstInput.length i++ i++ i {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			} {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			} seconInput = firstInput[i] seconInput firstInput[i] firstInput i num[i] = Character.getNumericValue(seconInput) num[i] num i Character.getNumericValue(seconInput) Character.getNumericValue Character seconInput if (num[0] == 0 && seconInput == '0' )break; num[0] == 0 && seconInput == '0' num[0] == 0 num[0] num 0 0 seconInput == '0' seconInput '0' break; int sum = 0; sum 0 for (int i = 0; i < num.length; i++) {

				sum += num[i];
			} int i = 0; int i = 0; i 0 i < num.length i num.length num num.length i++ i++ i {

				sum += num[i];
			} {

				sum += num[i];
			} sum += num[i] sum num[i] num 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) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	}
} public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	}
} Main


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		do {
			// input
			char[] firstInput = br.readLine().toCharArray(); // ex : 123
			int[] num = new int[firstInput.length];// base
			char seconInput = 0;
			for (int i = 0; i < firstInput.length; i++) {
				seconInput = firstInput[i];// split
				num[i] = Character.getNumericValue(seconInput);// input info
			}
			// constraints
			if (num[0] == 0 && seconInput == '0' )break;

			// plus works & output
			int sum = 0;
			for (int i = 0; i < num.length; i++) {

				sum += num[i];
			}
			System.out.println(sum);
		} while (true);
	}
}