import java.io.*;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	}
} import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	}
} Main public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] num; num int sum; sum do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true); true {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} sum = 0 sum 0 num = br.readLine().split("") num br.readLine().split("") br.readLine().split br.readLine() br.readLine br "" for (String str : num) sum += Integer.valueOf(str); String str num sum += Integer.valueOf(str); sum += Integer.valueOf(str) sum Integer.valueOf(str) Integer.valueOf Integer str if (sum == 0) break; sum == 0 sum 0 break; System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	}
} public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	}
} Main
import java.io.*;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] num;
		int sum;
		
		do {
			sum = 0;
			num = br.readLine().split("");
			
			for (String str : num) sum += Integer.valueOf(str);
			
			if (sum == 0) break;
			
			System.out.println(sum);

		} while (true);
		
	}
}