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();

		while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	}

} 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();

		while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	}

} 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();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();

		while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		} true {

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		} String input = br.readLine(); input br.readLine() br.readLine br if(input.equals("0")){
				break;
			} input.equals("0") input.equals input "0" {
				break;
			} break; int total = 0; total 0 char[] charAry = input.toCharArray(); charAry input.toCharArray() input.toCharArray input for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			} int i = 0; int i = 0; i 0 i < charAry.length i charAry.length charAry charAry.length i++ i++ i {
				total += Character.getNumericValue(charAry[i]);
			} {
				total += Character.getNumericValue(charAry[i]);
			} total += Character.getNumericValue(charAry[i]) total Character.getNumericValue(charAry[i]) Character.getNumericValue Character charAry[i] charAry i System.out.println(total) System.out.println System.out System System.out total 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();

		while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	}

} public 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();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	}

} 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();

		while(true){

			String input = br.readLine();
			if(input.equals("0")){
				break;
			}

			int total = 0;
			char[] charAry = input.toCharArray();
			for(int i = 0; i < charAry.length; i++){
				total += Character.getNumericValue(charAry[i]);
			}

			System.out.println(total);
		}


	}

}