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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	}
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	}
} Main public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) StringBuffer sb = new StringBuffer(); sb new StringBuffer() int i = 0; i 0 int j = 0; j 0 while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		} true {
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		} String input = br.readLine(); input br.readLine() br.readLine br if( input.equals("0") ) break; input.equals("0") input.equals input "0" break; for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			} i=0 ; i=0 i 0 i<input.length() i input.length() input.length input i++ i++ i {
				j = j + Integer.parseInt(input.substring(i, i+1));
			} {
				j = j + Integer.parseInt(input.substring(i, i+1));
			} j = j + Integer.parseInt(input.substring(i, i+1)) j j + Integer.parseInt(input.substring(i, i+1)) j Integer.parseInt(input.substring(i, i+1)) Integer.parseInt Integer input.substring(i, i+1) input.substring input i i+1 i 1 sb.append(Integer.toString(j)).append("\n") sb.append(Integer.toString(j)).append sb.append(Integer.toString(j)) sb.append sb Integer.toString(j) Integer.toString Integer j "\n" j = 0 j 0 System.out.print(sb) System.out.print System.out System System.out sb String[] age age public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	}
} public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		int i = 0;
		int j = 0;

		while( true ){
			String input = br.readLine();

			if( input.equals("0") ) break;

			for( i=0 ; i<input.length() ; i++ ){
				j = j + Integer.parseInt(input.substring(i, i+1));
			}
			sb.append(Integer.toString(j)).append("\n");
			j = 0;
		}
		System.out.print(sb);
	}
}