import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String line;
		line = sc.nextLine();
		int sum = 0;
		int i;

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String line;
		line = sc.nextLine();
		int sum = 0;
		int i;

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

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

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

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

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String line; line line = sc.nextLine() line sc.nextLine() sc.nextLine sc int sum = 0; sum 0 int i; i while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		} line.compareTo("0") != 0 line.compareTo("0") line.compareTo line "0" 0 {
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		} for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			} i = 0; i = 0 i 0 i < line.length() i line.length() line.length line i++ i++ i {
				sum += Character.getNumericValue(line.charAt(i));
			} {
				sum += Character.getNumericValue(line.charAt(i));
			} sum += Character.getNumericValue(line.charAt(i)) sum Character.getNumericValue(line.charAt(i)) Character.getNumericValue Character line.charAt(i) line.charAt line i System.out.println(sum) System.out.println System.out System System.out sum line = sc.nextLine() line sc.nextLine() sc.nextLine sc sum = 0 sum 0 String[] arg arg public class Main{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String line;
		line = sc.nextLine();
		int sum = 0;
		int i;

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

	}
} public class Main{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String line;
		line = sc.nextLine();
		int sum = 0;
		int i;

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		String line;
		line = sc.nextLine();
		int sum = 0;
		int i;

		while(line.compareTo("0") != 0){
			for(i = 0;i < line.length();i++){
				sum += Character.getNumericValue(line.charAt(i));
			}
			System.out.println(sum);
			line = sc.nextLine();
			sum = 0;
		}

	}
}
