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

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);

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

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\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();

		while(true){

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);

	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\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() while(true){

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\n");

		} true {

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\n");

		} String input = br.readLine(); input br.readLine() br.readLine br int sum = 0; sum 0 if(input.equals("0")){
				break;
			} input.equals("0") input.equals input "0" {
				break;
			} break; for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			} int i = 0; int i = 0; i 0 i < input.length() i input.length() input.length input i++ i++ i {
				sum += Character.digit(input.charAt(i), 10);
			} {
				sum += Character.digit(input.charAt(i), 10);
			} sum += Character.digit(input.charAt(i), 10) sum Character.digit(input.charAt(i), 10) Character.digit Character input.charAt(i) input.charAt input i 10 sb.append(sum + "\n") sb.append sb sum + "\n" sum "\n" System.out.print(sb) System.out.print System.out System System.out sb String[] args args
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			int sum = 0;

			if(input.equals("0")){
				break;
			}

			for(int i = 0; i < input.length(); i++){
				sum += Character.digit(input.charAt(i), 10);
			}

			sb.append(sum + "\n");

		}

		System.out.print(sb);

	}
}