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

// (1) true???????????\?????????????????????
	// (1.1) ???????????????????´????????????°sum???????????????
	// (1.2) ??????????????????????????????
	// (1.3) ?????????0???????????????????????´????????\?????????????????????
		// (1.3.1) ?????????????????????
	// (1.4) ??????????????????????????????????????°?????????1??????????????\?????????????????????
		// (1.4.1) ????±???¨??????1?????????char??????????????????
		// (1.4.2) char?????????????????????????????°?????????????????????
		// (1.4.3) ????¨?????????°sum????????°???????¶??????????????????????
	// (1.5) sum?????¨?????????

public class Main {
	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	}
} 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));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	}
} Main public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		} true {
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		} int sum = 0; sum 0 String num = br.readLine(); num br.readLine() br.readLine br if (num.equals("0")){
				break;
			} num.equals("0") num.equals num "0" {
				break;
			} break; for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			} int i = 0; int i = 0; i 0 i < num.length() i num.length() num.length num i++ i++ i {
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			} {
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			} char number = num.charAt(i); number num.charAt(i) num.charAt num i int numberCal = Character.getNumericValue(number); numberCal Character.getNumericValue(number) Character.getNumericValue Character number sum += numberCal sum numberCal 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));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

// (1) true???????????\?????????????????????
	// (1.1) ???????????????????´????????????°sum???????????????
	// (1.2) ??????????????????????????????
	// (1.3) ?????????0???????????????????????´????????\?????????????????????
		// (1.3.1) ?????????????????????
	// (1.4) ??????????????????????????????????????°?????????1??????????????\?????????????????????
		// (1.4.1) ????±???¨??????1?????????char??????????????????
		// (1.4.2) char?????????????????????????????°?????????????????????
		// (1.4.3) ????¨?????????°sum????????°???????¶??????????????????????
	// (1.5) sum?????¨?????????

public class Main {
	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String num = br.readLine();

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

			for (int i = 0;i < num.length();i++){
				char number = num.charAt(i);
				int numberCal = Character.getNumericValue(number);
				sum += numberCal;
			}
			System.out.println(sum);
		}
	}
}