import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	}

} import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	}

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

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		} true {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		} String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc if("0".equals(input)){
				break;
			} "0".equals(input) "0".equals "0" input {
				break;
			} break; long sum = 0; sum 0 for (char c : input.toCharArray()) {
				sum += (c - '0');
			} char c input.toCharArray() input.toCharArray input {
				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[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	}

} public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	}

} Main
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		while (true) {
			String input = sc.nextLine();

			if("0".equals(input)){
				break;
			}
			
			long sum = 0;
			for (char c : input.toCharArray()) {
				sum += (c - '0');
			}
			System.out.println(sum);
		}
	}

}