import java.util.Scanner;

public class Main {

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


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	}

} import java.util.Scanner; Scanner java.util public class Main {

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


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	}

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


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	} main {
		Scanner sc = new Scanner(System.in);
		int sum = 0;


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int sum = 0; sum 0 do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true); true {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		} sum = 0 sum 0 String n = sc.nextLine(); n sc.nextLine() sc.nextLine sc if(n.equals("0")) {
				break;
			} n.equals("0") n.equals n "0" {
				break;
			} break; String tmp[] = n.split(""); tmp n.split("") n.split n "" for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			} int i = 0; int i = 0; i 0 i < tmp.length i tmp.length tmp tmp.length i++ i++ i {
				sum += Integer.parseInt(tmp[i]);
			} {
				sum += Integer.parseInt(tmp[i]);
			} sum += Integer.parseInt(tmp[i]) sum Integer.parseInt(tmp[i]) Integer.parseInt Integer tmp[i] tmp i System.out.println(sum) System.out.println System.out System System.out sum sc.close() sc.close sc String[] args args public class Main {

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


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	}

} public class Main {

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


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	}

} Main
import java.util.Scanner;

public class Main {

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


		do {
			sum = 0;
			String n = sc.nextLine();


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

			String tmp[] = n.split("");

			for (int i = 0; i < tmp.length; i++) {
				sum += Integer.parseInt(tmp[i]);
			}

			System.out.println(sum);
		}while(true);

		sc.close();

	}

}
