import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	}
} Main public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	} main {
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		} true {
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		} String str=scan.next(); str scan.next() scan.next scan if(str.equals("0"))break; str.equals("0") str.equals str "0" break; int cnt=0; cnt 0 for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0'); int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i cnt+=(str.charAt(i)-'0'); cnt+=(str.charAt(i)-'0') cnt (str.charAt(i)-'0') str.charAt(i) str.charAt str i '0' System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	}
} public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		while(true){
			String str=scan.next();
			if(str.equals("0"))break;
			
			int cnt=0;
			for(int i=0;i<str.length();i++)
				cnt+=(str.charAt(i)-'0');
			
			System.out.println(cnt);
			
		}
		
	}
}
