import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String x;
		int total;
		while(true){
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		}
	}
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String x;
		int total;
		while(true){
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		}
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String x;
		int total;
		while(true){
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		String x;
		int total;
		while(true){
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String x; x int total; total while(true){
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		} true {
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		} x = sc.next() x sc.next() sc.next sc if (x.equals("0")){
				break;
			} x.equals("0") x.equals x "0" {
				break;
			} break; total = 0 total 0 for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			} int i = 0; int i = 0; i 0 i < x.length() i x.length() x.length x i++ i++ i {
				total += Integer.parseInt("" + x.charAt(i));
			} {
				total += Integer.parseInt("" + x.charAt(i));
			} total += Integer.parseInt("" + x.charAt(i)) total Integer.parseInt("" + x.charAt(i)) Integer.parseInt Integer "" + x.charAt(i) "" x.charAt(i) x.charAt x i System.out.println(total) System.out.println System.out System System.out total String[] args args
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String x;
		int total;
		while(true){
			x = sc.next();
			if (x.equals("0")){
				break;
			}
			total = 0;
			for (int i = 0; i < x.length(); i++){
				total += Integer.parseInt("" + x.charAt(i));
			}
			System.out.println(total);
		}
	}
}