import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	}

} import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	}

} Main public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	} main {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	} BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String s = in.readLine(); s in.readLine() in.readLine in while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		} !s.equals("0") s.equals("0") s.equals s "0" {
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		} int num = 0; num 0 for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			} int i = 0; int i = 0; i 0 i < s.length() i s.length() s.length s i++ i++ i {
				num += Integer.parseInt(s.substring(i, i+1));
			} {
				num += Integer.parseInt(s.substring(i, i+1));
			} num += Integer.parseInt(s.substring(i, i+1)) num Integer.parseInt(s.substring(i, i+1)) Integer.parseInt Integer s.substring(i, i+1) s.substring s i i+1 i 1 System.out.println(num) System.out.println System.out System System.out num s = in.readLine() s in.readLine() in.readLine in String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	}

} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	}

} Main
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = in.readLine();
		
		while(!s.equals("0")){
			int num = 0;
			for(int i = 0; i < s.length(); i++){
				num += Integer.parseInt(s.substring(i, i+1));
			}
			System.out.println(num);
			s = in.readLine();
		}
	}

}