import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	} main {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		} true {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		} String s = in.nextLine(); s in.nextLine() in.nextLine in if(s.equals("0")) return; s.equals("0") s.equals s "0" return; long ans = 0; ans 0 for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			} int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
				ans += Integer.parseInt(""+s.charAt(i));
			} {
				ans += Integer.parseInt(""+s.charAt(i));
			} ans += Integer.parseInt(""+s.charAt(i)) ans Integer.parseInt(""+s.charAt(i)) Integer.parseInt Integer ""+s.charAt(i) "" s.charAt(i) s.charAt s i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while (true) {
			String s = in.nextLine();
			if(s.equals("0")) return;
			long ans = 0;
			for(int i=0;i<s.length();i++) {
				ans += Integer.parseInt(""+s.charAt(i));
			}
			System.out.println(ans);
		}
	}
}