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();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
}
} 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();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
}
} Main public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
} main {
		Scanner scan=new Scanner(System.in);
		while(true) {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) while(true) {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		} true {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		} String str=scan.next(); str scan.next() scan.next scan int x=0; x 0 if(str.equals("0")) break; str.equals("0") str.equals str "0" break; for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
					x += str.charAt(i)-48;
				} {
					x += str.charAt(i)-48;
				} x += str.charAt(i)-48 x str.charAt(i)-48 str.charAt(i) str.charAt str i 48 System.out.println(x) System.out.println System.out System System.out x scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
}
} public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		while(true) {
			String str=scan.next();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
}
} 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();
			int x=0;
			if(str.equals("0")) break;
			for(int i=0;i<str.length();i++) {
					x += str.charAt(i)-48;
				}
			System.out.println(x);
		}
		scan.close();
}
}
