import java.util.Scanner;
/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		long sum=0;
		String str,dam;
		char line;
		
		while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		}
		
	}

} import java.util.Scanner; Scanner java.util class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		long sum=0;
		String str,dam;
		char line;
		
		while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		}
		
	}

} Main /**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		long sum=0;
		String str,dam;
		char line;
		
		while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		}
		
	} main {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		long sum=0;
		String str,dam;
		char line;
		
		while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		}
		
	} Scanner as = new Scanner(System.in); as new Scanner(System.in) long sum=0; sum 0 String str str dam; dam char line; line while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		} true {
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		} str = as.nextLine() str as.nextLine() as.nextLine as if(str.equals("0")){
				break;
			} str.equals("0") str.equals str "0" {
				break;
			} break; for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        } int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        } {      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        } line = str.charAt(i) line str.charAt(i) str.charAt str i sum = sum + Character.getNumericValue(line) sum sum + Character.getNumericValue(line) sum Character.getNumericValue(line) Character.getNumericValue Character line str = String.valueOf(sum) str String.valueOf(sum) String.valueOf String sum System.out.println(str) System.out.println System.out System System.out str sum = 0 sum 0 String[] args args
import java.util.Scanner;
/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		long sum=0;
		String str,dam;
		char line;
		
		while(true){
			
			str = as.nextLine();
			
			if(str.equals("0")){
				break;
			}
			
			for(int i=0;i<str.length();i++){      //?????????????????????????????????????´???????
	             
	            line = str.charAt(i);
	            sum = sum + Character.getNumericValue(line);
	            
	             
	        }
			str = String.valueOf(sum);
			System.out.println(str);
			sum = 0;
			
		}
		
	}

}