import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	}	
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	}	
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		} ; {
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		} {
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		} String x = sc.next(); x sc.next() sc.next sc if(x.equals("0"))break; x.equals("0") x.equals x "0" break; String[] strArray = x.split(""); strArray x.split("") x.split x "" int add = 0; add 0 for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			} int i = 0; int i = 0; i 0 i < strArray.length i strArray.length strArray strArray.length i++ i++ i {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			} {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			} int num = Integer.parseInt(strArray[i]); num Integer.parseInt(strArray[i]) Integer.parseInt Integer strArray[i] strArray i add += num add num System.out.println(add) System.out.println System.out System System.out add String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	}	
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	}	
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		for(;;){
			String x = sc.next();
			if(x.equals("0"))break;
			String[] strArray = x.split("");
			int add = 0;
			for (int i = 0; i < strArray.length; i++) {
				int num = Integer.parseInt(strArray[i]);
			    add += num;
			}
			System.out.println(add);
		}
	}	
}