import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		
		while(true){
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		}
		
		System.out.print(str);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		
		while(true){
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		}
		
		System.out.print(str);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		
		while(true){
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		}
		
		System.out.print(str);
	} main {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		
		while(true){
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		}
		
		System.out.print(str);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) StringBuilder str = new StringBuilder(); str new StringBuilder() while(true){
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		} true {
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		} String number = scan.next(); number scan.next() scan.next scan if(number.equals("0")) break; number.equals("0") number.equals number "0" break; int sum = 0; sum 0 for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			} int i = 0 ; int i = 0 ; i 0 i < number.length() i number.length() number.length number i++ i++ i {
				sum += Integer.parseInt("" + number.charAt(i));
			} {
				sum += Integer.parseInt("" + number.charAt(i));
			} sum += Integer.parseInt("" + number.charAt(i)) sum Integer.parseInt("" + number.charAt(i)) Integer.parseInt Integer "" + number.charAt(i) "" number.charAt(i) number.charAt number i str.append(sum + "\n") str.append str sum + "\n" sum "\n" System.out.print(str) System.out.print System.out System System.out str String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		StringBuilder str = new StringBuilder();
		
		while(true){
			String number = scan.next();
			if(number.equals("0")) break;
			int sum = 0;
			for(int i = 0 ; i < number.length() ; i++){
				sum += Integer.parseInt("" + number.charAt(i));
			}
			str.append(sum + "\n");
		}
		
		System.out.print(str);
	}
}