import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	} main {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String strIn = ""; strIn "" ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() int intSum = 0; intSum 0 while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		} true {
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		} strIn = scan.nextLine() strIn scan.nextLine() scan.nextLine scan if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			} "0".equals(strIn) "0".equals "0" strIn {
				break;
			} break; {
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			} intSum = 0 intSum 0 for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				} int i = 0; int i = 0; i 0 i < strIn.length() i strIn.length() strIn.length strIn i++ i++ i {
					intSum += Character.getNumericValue(strIn.charAt(i));
				} {
					intSum += Character.getNumericValue(strIn.charAt(i));
				} intSum += Character.getNumericValue(strIn.charAt(i)) intSum Character.getNumericValue(strIn.charAt(i)) Character.getNumericValue Character strIn.charAt(i) strIn.charAt strIn i list.add(intSum) list.add list intSum for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		} int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list i++ i++ i {
			System.out.println(list.get(i));
		} {
			System.out.println(list.get(i));
		} System.out.println(list.get(i)) System.out.println System.out System System.out list.get(i) list.get list i scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn = "";
		ArrayList<Integer> list = new ArrayList<Integer>();
		int intSum = 0;
		while(true){
			strIn = scan.nextLine();
			if("0".equals(strIn)){
				break;
			}else{
				intSum = 0;
				for(int i = 0; i < strIn.length(); i++){
					intSum += Character.getNumericValue(strIn.charAt(i));
				}
				list.add(intSum);
			}
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
}