import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
} Main void run(){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	} run {
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) String str = s.next(); str s.next() s.next s while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		} !"0".equals(str) "0".equals(str) "0".equals "0" str {
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		} int num = 0; num 0 String st[] = str.split(""); st str.split("") str.split str "" for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			} int i = 0; int i = 0; i 0 i < st.length i st.length st st.length i++ i++ i {
				num += Integer.valueOf(st[i]).intValue();
			} {
				num += Integer.valueOf(st[i]).intValue();
			} num += Integer.valueOf(st[i]).intValue() num Integer.valueOf(st[i]).intValue() Integer.valueOf(st[i]).intValue Integer.valueOf(st[i]) Integer.valueOf Integer st[i] st i System.out.println(num) System.out.println System.out System System.out num str = s.next() str s.next() s.next s public static void main(String args[]){
		Main m = new Main();
		m.run();
	} main {
		Main m = new Main();
		m.run();
	} Main m = new Main(); m new Main() m.run() m.run m String args[] args public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
} public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
} Main
import java.util.Scanner;
public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String str = s.next();
		while(!"0".equals(str)){
			int num = 0;
			String st[] = str.split("");
			for(int i = 0;i < st.length;i++){
				num += Integer.valueOf(st[i]).intValue();
			}
			System.out.println(num);
			str = s.next();
		}
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
}