import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long sum = 0;

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long sum = 0;

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long sum = 0;

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) long sum = 0; sum 0 while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		} true {
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		} sum = 0 sum 0 String str = br.readLine(); str br.readLine() br.readLine br if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			} str.length() >= 1 str.length() str.length str 1 {
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			} if(str.equals("0")){
					break;
				} str.equals("0") str.equals str "0" {
					break;
				} break; for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				} int i = 0; int i = 0; i 0 i < str.length() i str.length() str.length str i++ i++ i {
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				} {
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				} sum += Integer.parseInt(String.valueOf(str.charAt(i))) sum Integer.parseInt(String.valueOf(str.charAt(i))) Integer.parseInt Integer String.valueOf(str.charAt(i)) String.valueOf String str.charAt(i) str.charAt str i 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));
		long sum = 0;

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	}
} public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long sum = 0;

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		while(true){
			sum = 0;
			String str = br.readLine();
			if(str.length() >= 1){
				if(str.equals("0")){
					break;
				}
				for(int i = 0; i < str.length(); i++){
					sum += Integer.parseInt(String.valueOf(str.charAt(i)));
				}
			}
			System.out.println(sum);
		}
	}
}