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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
} 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 final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
} Main public static final int BIG_NUM  = 2000000000; BIG_NUM 2000000000 public static final int MOD  = 1000000007; MOD 1000000007 public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int ans; ans while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		} true {

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		} try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			} IOException e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} String inputed = br.readLine(); inputed br.readLine() br.readLine br if(inputed.length() == 1 && inputed.equals("0"))break; inputed.length() == 1 && inputed.equals("0") inputed.length() == 1 inputed.length() inputed.length inputed 1 inputed.equals("0") inputed.equals inputed "0" break; ans = 0 ans 0 for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				} int i = 0; int i = 0; i 0 i < inputed.length() i inputed.length() inputed.length inputed i++ i++ i {
					ans += inputed.charAt(i)-'0';
				} {
					ans += inputed.charAt(i)-'0';
				} ans += inputed.charAt(i)-'0' ans inputed.charAt(i)-'0' inputed.charAt(i) inputed.charAt inputed i '0' System.out.printf("%d\n", ans) System.out.printf System.out System System.out "%d\n" ans String[] args args public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
} public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int ans;

		while(true){

			try {
				String inputed = br.readLine();
				if(inputed.length() == 1 && inputed.equals("0"))break;

				ans = 0;
				for(int i = 0; i < inputed.length(); i++){
					ans += inputed.charAt(i)-'0';
				}

				System.out.printf("%d\n", ans);

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
