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