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

		while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
    }
} import java.io.*; io.* java class Main{
    public static void main(String[] args)throws IOException{
		long sum;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
    }
} Main public static void main(String[] args)throws IOException{
		long sum;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
    } main {
		long sum;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
    } long sum; sum BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		} true {
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		} sum = 0 sum 0 String inp = br.readLine(); inp br.readLine() br.readLine br if(inp.equals("0")){
				break;
			} inp.equals("0") inp.equals inp "0" {
				break;
			} break; char[] ch = inp.toCharArray(); ch inp.toCharArray() inp.toCharArray inp for(char c : ch){
				sum += Character.getNumericValue(c);
			} char c ch {
				sum += Character.getNumericValue(c);
			} {
				sum += Character.getNumericValue(c);
			} sum += Character.getNumericValue(c) sum Character.getNumericValue(c) Character.getNumericValue Character c System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.io.*;
 
class Main{
    public static void main(String[] args)throws IOException{
		long sum;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			sum = 0;
			String inp = br.readLine();
			if(inp.equals("0")){
				break;
			}
			char[] ch = inp.toCharArray();
			for(char c : ch){
				sum += Character.getNumericValue(c);
			}
			System.out.println(sum);
		}
    }
}