import java.util.Scanner;

/**
 * @author SS-1029
 *
 */
public class Main {

	public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	}

	/*
	 * ?¨??????????????????????
	 * @param String x
	 * @param return int sum
	 */
	public static int getSum(String x) {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	}

	/*
	 * ?¨??????????????????????
	 * @param String x
	 * @param return int sum
	 */
	public static int getSum(String x) {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	}

} Main public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	} main {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		} true {
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		} String x = scan.nextLine(); x scan.nextLine() scan.nextLine scan if(x.charAt(0) == '0'){
				break;
			} x.charAt(0) == '0' x.charAt(0) x.charAt x 0 '0' {
				break;
			} break; System.out.println(getSum(x)) System.out.println System.out System System.out getSum(x) getSum x String[] args args /*
	 * ?¨??????????????????????
	 * @param String x
	 * @param return int sum
	 */
	public static int getSum(String x) {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	} getSum {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	} int sum = 0; sum 0 for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		} {
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		} sum += Integer.parseInt(String.valueOf(x.charAt(i))) sum Integer.parseInt(String.valueOf(x.charAt(i))) Integer.parseInt Integer String.valueOf(x.charAt(i)) String.valueOf String x.charAt(i) x.charAt x i return sum; sum String x x public class Main {

	public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	}

	/*
	 * ?¨??????????????????????
	 * @param String x
	 * @param return int sum
	 */
	public static int getSum(String x) {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	}

} public class Main {

	public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	}

	/*
	 * ?¨??????????????????????
	 * @param String x
	 * @param return int sum
	 */
	public static int getSum(String x) {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	}

} Main
import java.util.Scanner;

/**
 * @author SS-1029
 *
 */
public class Main {

	public static void main(String[] args) {

		//??\??????????????????????????????Scanner???????????§???????????????
		Scanner scan = new Scanner(System.in);


		while(true){
			//??????????????????
			String x = scan.nextLine();
			//???????????¶
			if(x.charAt(0) == '0'){
				break;
			}
			//???????????¨???
			System.out.println(getSum(x));
		}
	}

	/*
	 * ?¨??????????????????????
	 * @param String x
	 * @param return int sum
	 */
	public static int getSum(String x) {

		//??????????????£?¨?
		int sum = 0;
		//char?????????????????°?????????
		for(int i = 0; i < x.length(); i++){
			//String?????????????????°?????????
			sum += Integer.parseInt(String.valueOf(x.charAt(i)));
		}
		return sum;
	}

}