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


class Main{
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		}
		}} 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 {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		}
		}} Main public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		}
		} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		}
		} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) while(true){
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		} true {
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		} String str=br.readLine(); str br.readLine() br.readLine br if(str.equals("0"))break; str.equals("0") str.equals str "0" break; int t=0; t 0 for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			} int i=0; int i=0; i 0 i<str.length() i str.length() str.length str i++ i++ i {
				t+=Character.getNumericValue(str.charAt(i));
			} {
				t+=Character.getNumericValue(str.charAt(i));
			} t+=Character.getNumericValue(str.charAt(i)) t Character.getNumericValue(str.charAt(i)) Character.getNumericValue Character str.charAt(i) str.charAt str i System.out.println(t) System.out.println System.out System System.out t 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 {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str=br.readLine();
			if(str.equals("0"))break;
			int t=0;
			for(int i=0;i<str.length();i++){
				t+=Character.getNumericValue(str.charAt(i));
			}System.out.println(t);
		}
		}}