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


public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	}

} 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 {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	}

} Main public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	} main {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	} String line; line BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		} (line = br.readLine()) != null (line = br.readLine()) line br.readLine() br.readLine br null {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		} if (line.equals("0")) {
				break;
			} line.equals("0") line.equals line "0" {
				break;
			} break; int sum = 0; sum 0 for (char c : line.toCharArray()) {
				sum += c - '0';
			} char c line.toCharArray() line.toCharArray line {
				sum += c - '0';
			} {
				sum += c - '0';
			} sum += c - '0' sum c - '0' c '0' 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 IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	}

} public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	}

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


public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0")) {
				break;
			}
			
			int sum = 0;
			for (char c : line.toCharArray()) {
				sum += c - '0';
			}
			
			System.out.println(sum);
		}
	}

}