import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	}
} Main public static Scanner sc; sc public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	} main {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	} int y[]=new int[2000]; y new int[2000] 2000 String[] strs = new String[2000]; strs new String[2000] 2000 char[] word = new char[2000]; word new char[2000] 2000 sc = new Scanner(System.in) sc new Scanner(System.in) int i=1; i 1 int j=0; j 0 int sum=0; sum 0 for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		} ; {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		} {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		} strs[i]=sc.next() strs[i] strs i sc.next() sc.next sc if(strs[i].equals("0")) {
				break;
			} strs[i].equals("0") strs[i].equals strs[i] strs i "0" {
				break;
			} break; i++ i i=1 i 1 for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		} ; {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		} {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		} if(strs[i].equals("0")) {
				break;
			} strs[i].equals("0") strs[i].equals strs[i] strs i "0" {
				break;
			} break; for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			} j=0; j=0 j 0 j<strs[i].length() j strs[i].length() strs[i].length strs[i] strs i j++ j++ j {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			} {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			} word[j]=strs[i].charAt(j) word[j] word j strs[i].charAt(j) strs[i].charAt strs[i] strs i j y[j]=Character.getNumericValue(word[j]) y[j] y j Character.getNumericValue(word[j]) Character.getNumericValue Character word[j] word j sum+=y[j] sum y[j] y j System.out.println(sum) System.out.println System.out System System.out sum i++ i sum=0 sum 0 String args[] args public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	}
} public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	}
}

