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

class Main{

	public static void main(String[] args) throws IOException
	{
		//int nMax;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		
		while(true)
		{
			String str = br.readLine();
			
			if(str.equals("0") ) break;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		}
	}
	
	static int SumDigit(char[] cArray)
	{
		int sum=0;
		int[] nArray = new int[cArray.length];
		
		for(int i=0; i<cArray.length; i++)
		{
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		}
		
		return sum;
	}
	
} 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
	{
		//int nMax;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		
		while(true)
		{
			String str = br.readLine();
			
			if(str.equals("0") ) break;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		}
	}
	
	static int SumDigit(char[] cArray)
	{
		int sum=0;
		int[] nArray = new int[cArray.length];
		
		for(int i=0; i<cArray.length; i++)
		{
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		}
		
		return sum;
	}
	
} Main public static void main(String[] args) throws IOException
	{
		//int nMax;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		
		while(true)
		{
			String str = br.readLine();
			
			if(str.equals("0") ) break;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		}
	} main {
		//int nMax;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		
		while(true)
		{
			String str = br.readLine();
			
			if(str.equals("0") ) break;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		}
	} 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;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		} true {
			String str = br.readLine();
			
			if(str.equals("0") ) break;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		} String str = br.readLine(); str br.readLine() br.readLine br if(str.equals("0") ) break; str.equals("0") str.equals str "0" break; char[] cArray = str.toCharArray(); cArray str.toCharArray() str.toCharArray str System.out.println(SumDigit(cArray) ) System.out.println System.out System System.out SumDigit(cArray) SumDigit cArray String[] args args static int SumDigit(char[] cArray)
	{
		int sum=0;
		int[] nArray = new int[cArray.length];
		
		for(int i=0; i<cArray.length; i++)
		{
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		}
		
		return sum;
	} SumDigit {
		int sum=0;
		int[] nArray = new int[cArray.length];
		
		for(int i=0; i<cArray.length; i++)
		{
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		}
		
		return sum;
	} int sum=0; sum 0 int[] nArray = new int[cArray.length]; nArray new int[cArray.length] cArray.length cArray cArray.length for(int i=0; i<cArray.length; i++)
		{
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		} int i=0; int i=0; i 0 i<cArray.length i cArray.length cArray cArray.length i++ i++ i {
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		} {
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		} nArray[i] = Character.getNumericValue(cArray[i]) nArray[i] nArray i Character.getNumericValue(cArray[i]) Character.getNumericValue Character cArray[i] cArray i sum += nArray[i] sum nArray[i] nArray i return sum; sum char[] cArray cArray
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws IOException
	{
		//int nMax;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		
		while(true)
		{
			String str = br.readLine();
			
			if(str.equals("0") ) break;
			
			char[] cArray = str.toCharArray();
			
			System.out.println(SumDigit(cArray) );
		}
	}
	
	static int SumDigit(char[] cArray)
	{
		int sum=0;
		int[] nArray = new int[cArray.length];
		
		for(int i=0; i<cArray.length; i++)
		{
			nArray[i] = Character.getNumericValue(cArray[i]);
			sum += nArray[i];
			
		}
		
		return sum;
	}
	
}