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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	}
} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int sum; sum while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		} true {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		} String line = br.readLine(); line br.readLine() br.readLine br if("0".equals(line)) {
				break;
			} "0".equals(line) "0".equals "0" line {
				break;
			} break; char[] c = line.toCharArray(); c line.toCharArray() line.toCharArray line sum = 0 sum 0 for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			} int i = 0; int i = 0; i 0 i < c.length i c.length c c.length ++i ++i i {
				sum += Character.getNumericValue(c[i]);
			} {
				sum += Character.getNumericValue(c[i]);
			} sum += Character.getNumericValue(c[i]) sum Character.getNumericValue(c[i]) Character.getNumericValue Character c[i] c i sb.append(sum).append("\n") sb.append(sum).append sb.append(sum) sb.append sb sum "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int sum;
		while(true) {
			String line = br.readLine();
			if("0".equals(line)) {
				break;
			}
			char[] c = line.toCharArray();
			sum = 0;
			for(int i = 0; i < c.length; ++i) {
				sum += Character.getNumericValue(c[i]);
			}
			sb.append(sum).append("\n");
		}
		System.out.print(sb);
	}
}