import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	}
} Main public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) ArrayList<Integer> ans = new ArrayList<Integer>(); ans new ArrayList<Integer>() char ch[] = new char[1000]; ch new char[1000] 1000 int len len sum; sum String str; str while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		} true {
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		} str = br.readLine() str br.readLine() br.readLine br if(str.equals("0")){
				break;
			} str.equals("0") str.equals str "0" {
				break;
			} break; sum = 0 sum 0 len = str.length() len str.length() str.length str ch = str.toCharArray() ch str.toCharArray() str.toCharArray str for(char c : ch){
				sum += Character.digit(c, 10);
			} char c ch {
				sum += Character.digit(c, 10);
			} {
				sum += Character.digit(c, 10);
			} sum += Character.digit(c, 10) sum Character.digit(c, 10) Character.digit Character c 10 ans.add(sum) ans.add ans sum for(int i : ans){
			System.out.println(i);
		} int i ans {
			System.out.println(i);
		} {
			System.out.println(i);
		} System.out.println(i) System.out.println System.out System System.out i String args[] args public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	}
} public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	}
} Main
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> ans = new ArrayList<Integer>();
		char ch[] = new char[1000];
		int len, sum;
		String str;
		
		while(true){
			str = br.readLine();
			if(str.equals("0")){
				break;
			}
			
			sum = 0;
			len = str.length();
			ch = str.toCharArray();
			
			for(char c : ch){
				sum += Character.digit(c, 10);
			}
			
			ans.add(sum);
		}
		
		for(int i : ans){
			System.out.println(i);
		}
	}
}