import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	} main {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		} true {
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		} int sum = 0; sum 0 String num = scan.next(); num scan.next() scan.next scan if(num.equals("0")){
				scan.close();
				break;
			} num.equals("0") num.equals num "0" {
				scan.close();
				break;
			} scan.close() scan.close scan break; char subnum[] = num.toCharArray(); subnum num.toCharArray() num.toCharArray num for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			} int i = 0; int i = 0; i 0 i < subnum.length i subnum.length subnum subnum.length i++ i++ i {
				sum += Character.getNumericValue(subnum[i]);
			} {
				sum += Character.getNumericValue(subnum[i]);
			} sum += Character.getNumericValue(subnum[i]) sum Character.getNumericValue(subnum[i]) Character.getNumericValue Character subnum[i] subnum i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			int sum = 0;
			String num = scan.next();
			if(num.equals("0")){
				scan.close();
				break;
			}
			char subnum[] = num.toCharArray();
			for(int i = 0; i < subnum.length; i++){
				sum += Character.getNumericValue(subnum[i]);
			}
			System.out.println(sum);
		}
	}
}