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

class Main {

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

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

		String str = br.readLine();

		int sum = 0;

		while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		}

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

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

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

		String str = br.readLine();

		int sum = 0;

		while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		}

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

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

		String str = br.readLine();

		int sum = 0;

		while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		}

	} main {

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

		String str = br.readLine();

		int sum = 0;

		while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		}

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String str = br.readLine(); str br.readLine() br.readLine br int sum = 0; sum 0 while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		} !(str.equals("0")) (str.equals("0")) str.equals str "0" {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		} sum =0 sum 0 for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			} int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			} {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			} sum += Integer.parseInt(String.valueOf(str.charAt(i))) sum Integer.parseInt(String.valueOf(str.charAt(i))) Integer.parseInt Integer String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i System.out.println(sum) System.out.println System.out System System.out sum str = br.readLine() str br.readLine() br.readLine br String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

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

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

		String str = br.readLine();

		int sum = 0;

		while (!(str.equals("0"))) {

			sum =0;

			for (int i = 0; i < str.length(); i++) {
				sum += Integer.parseInt(String.valueOf(str.charAt(i)));
			}
			System.out.println(sum);

			str = br.readLine();
		}

	}
}