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

class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[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 class Main {

	public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		}
	}
} Main public static void main(String args[]) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		}
	} main {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		}
	} InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		} true {
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		} String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("0"))break; str.equals("0") str.equals str "0" break; char ch[] = str.toCharArray(); ch str.toCharArray() str.toCharArray str int sum = 0; sum 0 for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			} int i = 0; int i = 0; i 0 i < ch.length i ch.length ch ch.length i++ i++ i {
				sum += Character.getNumericValue(ch[i]); 
			} {
				sum += Character.getNumericValue(ch[i]); 
			} sum += Character.getNumericValue(ch[i]) sum Character.getNumericValue(ch[i]) Character.getNumericValue Character ch[i] ch i System.out.println(sum) System.out.println System.out System System.out sum 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 {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		
		while(true){
			
			String str = br.readLine();
			
			if(str.equals("0"))break;
			
			char ch[] = str.toCharArray();
			
			int sum = 0;
			for(int i = 0; i < ch.length; i++){
				sum += Character.getNumericValue(ch[i]); 
			}	
			System.out.println(sum);
		}
	}
}