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

/**
 * 1_8_B
 * @author yosuke
 *
 */
public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	}

} Main public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	} main {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	} int sum = 0; sum 0 String tmp1; tmp1 int tmp2; tmp2 String str; str ArrayList<String> arrayStr = new ArrayList<String>(); arrayStr new ArrayList<String>() ArrayList<Integer> answerArray = new ArrayList<Integer>(); answerArray new ArrayList<Integer>() BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		} true {
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		} str = br.readLine() str br.readLine() br.readLine br if(str.equals("0")){
				break;
			} str.equals("0") str.equals str "0" {
				break;
			} break; arrayStr.add(str) arrayStr.add arrayStr str int arraySize = arrayStr.size(); arraySize arrayStr.size() arrayStr.size arrayStr for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		} int i = 0; int i = 0; i 0 i <arraySize i arraySize ++i ++i i {
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		} {
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		} tmp1 = arrayStr.get(i) tmp1 arrayStr.get(i) arrayStr.get arrayStr i for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			} int j = 0; int j = 0; j 0 j < tmp1.length() j tmp1.length() tmp1.length tmp1 ++j ++j j {
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			} {
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			} tmp2 = tmp1.charAt(j)-'0' tmp2 tmp1.charAt(j)-'0' tmp1.charAt(j) tmp1.charAt tmp1 j '0' sum += tmp2 sum tmp2 answerArray.add(sum) answerArray.add answerArray sum sum = 0 sum 0 for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		} int i = 0; int i = 0; i 0 i < answerArray.size() i answerArray.size() answerArray.size answerArray ++i ++i i {
			System.out.println(answerArray.get(i));
		} {
			System.out.println(answerArray.get(i));
		} System.out.println(answerArray.get(i)) System.out.println System.out System System.out answerArray.get(i) answerArray.get answerArray i String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

/**
 * 1_8_B
 * @author yosuke
 *
 */
public class Main {

	public static void main(String[] args) throws IOException {
		int sum = 0;
		String tmp1;
		int tmp2;
		String str;
		ArrayList<String> arrayStr = new ArrayList<String>();
		ArrayList<Integer> answerArray = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			arrayStr.add(str);
		}
		int arraySize = arrayStr.size();
		for(int i = 0; i <arraySize; ++i){
			tmp1 = arrayStr.get(i);
			for(int j = 0; j < tmp1.length(); ++j){
				tmp2 = tmp1.charAt(j)-'0'; //??¢????????????????????§??????
				sum += tmp2;
			}
			answerArray.add(sum);
			sum = 0;
		}
		for(int i = 0; i < answerArray.size(); ++i ){
			System.out.println(answerArray.get(i));
		}
	}

}