import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	}
} import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	} main {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	} while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		} true {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		} String s = sc.next(); s sc.next() sc.next sc if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			} s.equals("0") s.equals s "0" {break;} break; {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			} int sum = 0; sum 0 for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				} {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				} int n = Integer.parseInt(String.valueOf(s.charAt(i))); n Integer.parseInt(String.valueOf(s.charAt(i))) Integer.parseInt Integer String.valueOf(s.charAt(i)) String.valueOf String s.charAt(i) s.charAt s i sum += n sum n System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	}
} Main
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			String s = sc.next();
			if (s.equals("0")) {break;}
			else {
				int sum = 0;
				for (int i=0; i<s.length(); i++) {
					int n = Integer.parseInt(String.valueOf(s.charAt(i)));
					sum += n;
				}
				System.out.println(sum);
			}
		}
	}
}
