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

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

    	while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	}
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io class Main{
	public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String input;
    	int total = 0;

    	while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	}
    }
} Main public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String input;
    	int total = 0;

    	while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	}
    } main {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String input;
    	int total = 0;

    	while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	}
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String input; input int total = 0; total 0 while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	} (input = br.readLine()) != null (input = br.readLine()) input br.readLine() br.readLine br null {
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	} if(input.equals("0")) break; input.equals("0") input.equals input "0" break; char[] cArray = input.toCharArray(); cArray input.toCharArray() input.toCharArray input for(char c : cArray){
    			total += Character.getNumericValue(c);
    		} char c cArray {
    			total += Character.getNumericValue(c);
    		} {
    			total += Character.getNumericValue(c);
    		} total += Character.getNumericValue(c) total Character.getNumericValue(c) Character.getNumericValue Character c System.out.println(total) System.out.println System.out System System.out total total = 0 total 0 String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

    	while((input = br.readLine()) != null){
    		if(input.equals("0")) break;
    		char[] cArray = input.toCharArray();
    		for(char c : cArray){
    			total += Character.getNumericValue(c);
    		}
    		System.out.println(total);
    		total = 0;
    	}
    }
}