import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		}
	}
} import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		}
	}
} Main public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		}
	} main {
		Scanner sc= new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		}
	} Scanner sc= new Scanner(System.in); sc new Scanner(System.in) while(true){
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		} true {
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		} String line = sc.nextLine(); line sc.nextLine() sc.nextLine sc if(line.equals("0")){
				break;
			} line.equals("0") line.equals line "0" {
				break;
			} break; int sum=0; sum 0 for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			} int i=0; int i=0; i 0 i<line.length() i line.length() line.length line i++ i++ i {
				sum+=Integer.parseInt(line.substring(i,i+1));
			} {
				sum+=Integer.parseInt(line.substring(i,i+1));
			} sum+=Integer.parseInt(line.substring(i,i+1)) sum Integer.parseInt(line.substring(i,i+1)) Integer.parseInt Integer line.substring(i,i+1) line.substring line i i+1 i 1 System.out.println(sum) System.out.println System.out System System.out sum String[] args args
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		while(true){
			String line = sc.nextLine();
			if(line.equals("0")){
				break;
			}
			int sum=0;
			for(int i=0;i<line.length();i++){
				sum+=Integer.parseInt(line.substring(i,i+1));
			}
			System.out.println(sum);
		}
	}
}