

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

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

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

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

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

		}
	} main {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		} true {

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		} String number = in.next(); number in.next() in.next in int ans = 0; ans 0 if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			} number.equals("0") number.equals number "0" {

				break;

			} break; {

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			} String[] numbers = number.split(""); numbers number.split("") number.split number "" for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				} int i = 0; int i = 0; i 0 i < numbers.length i numbers.length numbers numbers.length i++ i++ i {

					ans += Integer.parseInt(numbers[i]);

				} {

					ans += Integer.parseInt(numbers[i]);

				} ans += Integer.parseInt(numbers[i]) ans Integer.parseInt(numbers[i]) Integer.parseInt Integer numbers[i] numbers i list.add(ans) list.add list ans for(int result: list){

			System.out.println(result);

		} int result list {

			System.out.println(result);

		} {

			System.out.println(result);

		} System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

		}
	}
} Main


import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<>();

		while(true){

			String number = in.next();
			int ans = 0;

			if(number.equals("0")){

				break;

			}else{

				String[] numbers = number.split("");

				for(int i = 0; i < numbers.length; i++){

					ans += Integer.parseInt(numbers[i]);

				}
			}

			list.add(ans);

		}

		for(int result: list){

			System.out.println(result);

		}
	}
}