import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		}
	}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		}
	}

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

		Scanner scan = new Scanner(System.in);

		for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		}
	} main {

		Scanner scan = new Scanner(System.in);

		for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		} ; {
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		} {
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		} String str = scan.next(); str scan.next() scan.next scan if(str.equals("0"))
				break; str.equals("0") str.equals str "0" break; int ans = 0; ans 0 for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				ans += Character.getNumericValue(str.charAt(i));
			} {
				ans += Character.getNumericValue(str.charAt(i));
			} ans += Character.getNumericValue(str.charAt(i)) ans Character.getNumericValue(str.charAt(i)) Character.getNumericValue Character str.charAt(i) str.charAt str i System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		}
	}

}