import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	}
} import java.io.*; io.* java public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		} true {
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		} int sum = 0; sum 0 String str = br.readLine(); str br.readLine() br.readLine br if(str.equals( "0")){
					break;
				} str.equals( "0") str.equals str "0" {
					break;
				} break; for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				} char c str.toCharArray() str.toCharArray str {
					sum += Integer.parseInt("" + c);
				} {
					sum += Integer.parseInt("" + c);
				} sum += Integer.parseInt("" + c) sum Integer.parseInt("" + c) Integer.parseInt Integer "" + c "" c System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	}
} public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	}
} Main
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int sum = 0;
			String str = br.readLine();
				if(str.equals( "0")){
					break;
				}

				for(char c : str.toCharArray()){
					sum += Integer.parseInt("" + c);
				}
			System.out.println(sum);
		}
	}
}