import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	}
} Main private static Scanner sc=new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	} main {
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	} while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		} true {
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		} String str=sc.nextLine(); str sc.nextLine() sc.nextLine sc if(str.equals("0")) break; str.equals("0") str.equals str "0" break; int[] ch=new int[str.length()]; ch new int[str.length()] str.length() str.length str int sum=0; sum 0 for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			} {
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			} ch[i]=Character.getNumericValue(str.charAt(i)) ch[i] ch i Character.getNumericValue(str.charAt(i)) Character.getNumericValue Character str.charAt(i) str.charAt str i sum=sum+ch[i] sum sum+ch[i] sum ch[i] ch i System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	}
} public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		while(true){
			String str=sc.nextLine();
			if(str.equals("0")) break;
			int[] ch=new int[str.length()];
			int sum=0;
			for(int i=0;i<str.length();i++){
				ch[i]=Character.getNumericValue(str.charAt(i));
				sum=sum+ch[i];
			}
			System.out.println(sum);
		}
	}
}