import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	}

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

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	}

} Main public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	} main {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		} true {
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		} String x = scan.next(); x scan.next() scan.next scan if(x.equals ("0")) break; x.equals ("0") x.equals x "0" break; int sl = x.length(); sl x.length() x.length x int total = 0; total 0 for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			} int i=0; int i=0; i 0 i<sl i sl i++ i++ i {
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			} {
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			} String s = x.substring(i, i+1); s x.substring(i, i+1) x.substring x i i+1 i 1 int X = Integer.parseInt(s); X Integer.parseInt(s) Integer.parseInt Integer s total = total + X total total + X total X System.out.println(total) System.out.println System.out System System.out total String[] args args public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	}

} public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);

		while(true){
			String x = scan.next();
			if(x.equals ("0")) break;
			
			int sl = x.length();
			int total = 0;
			for(int i=0; i<sl; i++){
				String s = x.substring(i, i+1);
				int X = Integer.parseInt(s);
				total = total + X;
			}
			System.out.println(total);
		}
	
	}

}