import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int count=0; count 0 while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		} sc.hasNext() sc.hasNext sc {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		} String s = sc.next(); s sc.next() sc.next sc if(s.equals("0")) {
				break;
			} s.equals("0") s.equals s "0" {
				break;
			} break; count=0 count 0 for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			} {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			} char c = s.charAt(i); c s.charAt(i) s.charAt s i int digit = c - '0'; digit c - '0' c '0' count+=digit count digit System.out.printf("%d\n", count) System.out.printf System.out System System.out "%d\n" count String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count=0;
		while(sc.hasNext()) {
			String s = sc.next();
			if(s.equals("0")) {
				break;
			}
			count=0;
			for(int i=0; i<s.length(); i++) {
				char c = s.charAt(i);
				int digit = c - '0';
				count+=digit;
			}
			System.out.printf("%d\n", count);
		}
	}
}

