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

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	}
}
 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[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	}
} Main public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	} main {
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	} BufferedReader input = new BufferedReader (new InputStreamReader (System.in)); input new BufferedReader (new InputStreamReader (System.in)) for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		} ; {
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		} {
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		} String originNum = input.readLine(); originNum input.readLine() input.readLine input char[] numbersC = originNum.toCharArray(); numbersC originNum.toCharArray() originNum.toCharArray originNum String[] numbersS = new String[numbersC.length]; numbersS new String[numbersC.length] numbersC.length numbersC numbersC.length for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			} int num = 0; int num = 0; num 0 num < numbersC.length num numbersC.length numbersC numbersC.length num++ num++ num {
				numbersS[num] = String.valueOf(numbersC[num]);
			} {
				numbersS[num] = String.valueOf(numbersC[num]);
			} numbersS[num] = String.valueOf(numbersC[num]) numbersS[num] numbersS num String.valueOf(numbersC[num]) String.valueOf String numbersC[num] numbersC num int[] numbers = new int[numbersS.length]; numbers new int[numbersS.length] numbersS.length numbersS numbersS.length for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			} int num = 0; int num = 0; num 0 num < numbersS.length num numbersS.length numbersS numbersS.length num++ num++ num {
				numbers[num] = Integer.parseInt(numbersS[num]);
			} {
				numbers[num] = Integer.parseInt(numbersS[num]);
			} numbers[num] = Integer.parseInt(numbersS[num]) numbers[num] numbers num Integer.parseInt(numbersS[num]) Integer.parseInt Integer numbersS[num] numbersS num if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			} (numbers[0] == 0)&&(numbers.length == 1) (numbers[0] == 0) numbers[0] numbers 0 0 (numbers.length == 1) numbers.length numbers numbers.length 1 {
				break;
			} break; int sum = 0; sum 0 for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			} int num = 0; int num = 0; num 0 num < numbers.length num numbers.length numbers numbers.length num++ num++ num {
				sum = sum + numbers[num];
			} {
				sum = sum + numbers[num];
			} sum = sum + numbers[num] sum sum + numbers[num] sum numbers[num] numbers num System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	}
} public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));

		//与えられた数の各桁の和を計算する
		for(;;)
		{
			String originNum = input.readLine();

			char[] numbersC = originNum.toCharArray();

			String[] numbersS = new String[numbersC.length];

			//char型からString型に変換
			for(int num = 0; num < numbersC.length; num++)
			{
				numbersS[num] = String.valueOf(numbersC[num]);
			}

			int[] numbers = new int[numbersS.length];

			//String型からint型に変換
			for(int num = 0; num < numbersS.length; num++)
			{
				numbers[num] = Integer.parseInt(numbersS[num]);
			}

			if((numbers[0] == 0)&&(numbers.length == 1))
			{
				break;
			}

			int sum = 0;

			//数の各桁の和を計算する
			for(int num = 0; num < numbers.length; num++)
			{
				sum = sum + numbers[num];
			}

			System.out.println(sum);
		}
	}
}

