public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	}

} public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	}

} Main public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	} main {
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	} java.util.Scanner scan = new java.util.Scanner(System.in); scan new java.util.Scanner(System.in) while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		} true {
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		} String x = scan.nextLine(); x scan.nextLine() scan.nextLine scan if("0".equals(x)){
				break;
			} "0".equals(x) "0".equals "0" x {
				break;
			} break; int sum = 0; sum 0 for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			} char v x.toCharArray() x.toCharArray x {
				sum += Integer.parseInt(String.valueOf(v));
			} {
				sum += Integer.parseInt(String.valueOf(v));
			} sum += Integer.parseInt(String.valueOf(v)) sum Integer.parseInt(String.valueOf(v)) Integer.parseInt Integer String.valueOf(v) String.valueOf String v 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){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	}

} public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	}

} Main
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String x = scan.nextLine();
			if("0".equals(x)){
				break;
			}
			int sum = 0;
			for(char v : x.toCharArray()){
				sum += Integer.parseInt(String.valueOf(v));
			}
			System.out.println(sum);
		}
	}

}