import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	}
} Main public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	} main {

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) List<Integer> sums = new ArrayList<Integer>(); sums new ArrayList<Integer>() for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		} ; {
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		} {
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		} String num = scan.nextLine(); num scan.nextLine() scan.nextLine scan if(num.equals("0")){
				break;
			} num.equals("0") num.equals num "0" {
				break;
			} break; int sum = 0; sum 0 for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			} int i = 0; int i = 0; i 0 i < num.length() i num.length() num.length num i++ i++ i {
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			} {
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			} char n = num.charAt(i); n num.charAt(i) num.charAt num i sum += Character.getNumericValue(n) sum Character.getNumericValue(n) Character.getNumericValue Character n sums.add(sum) sums.add sums sum for(int m : sums){
			System.out.println(m);
		} int m sums {
			System.out.println(m);
		} {
			System.out.println(m);
		} System.out.println(m) System.out.println System.out System System.out m String[] args args public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	}
} public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	}
} Main
import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		List<Integer> sums = new ArrayList<Integer>();
		for(;;){
			String num = scan.nextLine();
			if(num.equals("0")){
				break;
			}
			int sum = 0;
			for(int i = 0; i < num.length(); i++){
				char n = num.charAt(i);
				sum += Character.getNumericValue(n);
			}
			sums.add(sum);
		}

		for(int m : sums){
			System.out.println(m);
		}
	}
}